# satoshi-bitcoin

> Convert Satoshi Bitcoin

Latest version **1.0.7** (published 2026-08-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install satoshi-bitcoin
pnpm add satoshi-bitcoin
yarn add satoshi-bitcoin
bun add satoshi-bitcoin
```

## Health

**Score 65/100 (B)** — status: active.

Positive: has types; no vulnerabilities; recently updated; high maintenance score; high quality score.

Warnings: low downloads; no esm support.

## Facts

| | |
|---|---|
| Version | 1.0.7 |
| Published | 2026-08-04 |
| First published | 2015-07-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >0.10 |
| Dependencies | 1 |
| Unpacked size | 25.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 42 |
| Author | Dawson Botsford |
| Maintainers | dawsonbotsford |
| Keywords | bitcoin, satoshi, conversion, cryptocurrency, math, arbitrary, precision, arithmetic, big, integer, int, number, biginteger, bigint, bignumber, decimal, float |

## Links

- npm: https://www.npmjs.com/package/satoshi-bitcoin
- Repository: https://github.com/dawsbot/satoshi-bitcoin
- Homepage: https://github.com/dawsbot/satoshi-bitcoin#readme
- Issues: https://github.com/dawsbot/satoshi-bitcoin/issues
- npm.io page: https://npm.io/package/satoshi-bitcoin

## Dependencies (1)

- [big.js](https://npm.io/package/big.js.md) ^3.1.3

## Alternatives

- [random-seedable](https://npm.io/package/random-seedable.md) — 27.9K weekly downloads
- [n2words](https://npm.io/package/n2words.md) — 22.2K weekly downloads
- [@stdlib/math-base-special-factorialln](https://npm.io/package/@stdlib/math-base-special-factorialln.md) — 5.7K weekly downloads
- [@stdlib/math-base-special-abs2](https://npm.io/package/@stdlib/math-base-special-abs2.md) — 1.7K weekly downloads
- [commons-math-interpolation](https://npm.io/package/commons-math-interpolation.md) — 1.4K weekly downloads

## Recent versions

- 1.0.7 (latest) — 2026-08-04
- 1.0.6 — 2026-07-08
- 1.0.5 — 2021-05-30
- 1.0.4 — 2016-08-19
- 1.0.2 — 2016-05-18
- 1.0.1 — 2016-03-20
- 1.0.0 — 2016-03-05
- 0.3.5 — 2016-03-01
- 0.3.4 — 2016-03-01
- 0.3.3 — 2016-03-01
- 0.3.2 — 2016-03-01
- 0.3.0 — 2015-08-01
- 0.2.0 — 2015-07-28
- 0.1.2 — 2015-07-24
- 0.1.1 — 2015-07-23
- … 1 more at https://npm.io/package/satoshi-bitcoin/versions

## README

# satoshi-bitcoin

[![bundle size](https://img.shields.io/bundlejs/size/satoshi-bitcoin)](https://bundlejs.com/?q=satoshi-bitcoin)
[![npm version](https://badge.fury.io/js/satoshi-bitcoin.svg)](https://badge.fury.io/js/satoshi-bitcoin)

[![node 8](https://github.com/dawsbot/satoshi-bitcoin/actions/workflows/node-8.yml/badge.svg)](https://github.com/dawsbot/satoshi-bitcoin/actions/workflows/node-8.yml)
[![node 12](https://github.com/dawsbot/satoshi-bitcoin/actions/workflows/node-12.yml/badge.svg)](https://github.com/dawsbot/satoshi-bitcoin/actions/workflows/node-12.yml)
[![node 16](https://github.com/dawsbot/satoshi-bitcoin/actions/workflows/node-16.yml/badge.svg)](https://github.com/dawsbot/satoshi-bitcoin/actions/workflows/node-16.yml)
[![node latest](https://github.com/dawsbot/satoshi-bitcoin/actions/workflows/node-latest.yml/badge.svg)](https://github.com/dawsbot/satoshi-bitcoin/actions/workflows/node-latest.yml)

> npm module to convert between Satoshi and Bitcoin <b>with lightweight precision</b>.

<br>

## The Problem

![The problem](https://i.imgur.com/H1Ck3bF.png)

<br>

## Install

```bash
npm install --save satoshi-bitcoin

# OR

yarn add satoshi-bitcoin
```

<br>

## Usage

#### Node.js

```js
var sb = require("satoshi-bitcoin");

sb.toSatoshi(1);
//=>100000000

sb.toBitcoin(100000000);
//=>1
```

<br>

#### Web

```html
<!-- package injected as "sb" -->
<script src="https://cdn.jsdelivr.net/npm/satoshi-bitcoin/index.bundle.js"></script>
<script>
  console.log("One Satoshi equals " + sb.toBitcoin(1) + " Bitcoin");
</script>
```

<br>

Or download it with `npm install --save satoshi-bitcoin` and reference it as:

```html
<script src="node_modules/satoshi-bitcoin/index.bundle.js"></script>
```

<br>

### Error Handling

```javascript
try {
  sb.toSatoshi(false); //Throws TypeError
} catch (err) {
  console.log(err);
}
```

<br>

## API

`sb.toSatoshi(number || string)`
`sb.toBitcoin(number || string)`

TypeScript definitions are included — both functions accept a `number` or `string` and return a `number`.

<br>

## FAQ

- What is a Satoshi?

  - Satoshi is to Bitcoin as pennies are to the dollar. Except that there are 100,000,000 Satoshi in one Bitcoin.

- Why do I need a module when I can just divide or multiply by 100,000,000?
  - [See here](https://repl.it/zlF/4) - Floating point errors are a problem. So `satoshi-bitcoin` uses a tiny bignum library (big.js) to ensure accurate conversions!

<br>

## Tests

```bash
npm test
```

<br>

## License

MIT © [Dawson Botsford](https://dawsbot.com)

---
_Source: https://npm.io/package/satoshi-bitcoin · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
