# prettydigits

> Prettifies large numbers into readable human numbers

Latest version **1.1.3** (published 2023-10-29) · MIT license · 0 weekly downloads

## Install

```sh
npm install prettydigits
pnpm add prettydigits
yarn add prettydigits
bun add prettydigits
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.3 |
| Published | 2023-10-29 |
| First published | 2023-10-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 6.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Matthew Davies |
| Maintainers | mattdevz |
| Keywords | tiny, large, unreadable, readable, big, numbers, shorten, format, millions, billions, trillions, prettyDigits, thousands, abbreviate |

## Links

- npm: https://www.npmjs.com/package/prettydigits
- Repository: https://github.com/matt-davz/PrettyDigits
- Homepage: https://github.com/matt-davz/PrettyDigits#readme
- Issues: https://github.com/matt-davz/PrettyDigits/issues
- npm.io page: https://npm.io/package/prettydigits

## 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.1.3 (latest) — 2023-10-29
- 1.1.2 — 2023-10-29
- 1.1.1 — 2023-10-29
- 1.1.0 — 2023-10-29
- 1.0.5 — 2023-10-28
- 1.0.4 — 2023-10-27
- 1.0.3 — 2023-10-27
- 1.0.2 — 2023-10-26
- 1.0.1 — 2023-10-26
- 1.0.0 — 2023-10-26

## README

# PrettyDigits

Changes long 'ugly' `numbers` into short pretty and readable `strings` 🌸

## Install with NPM
```
npm i prettydigits
```

| Before      | Command      | After       |
|-------------|-------------|-------------|
| `1000`      | `prettyDigits(1000)`     | `'1 K'`     |
| `10000`     | `prettyDigits(10000)`    | `'10 K'`    |
| `1000000`   | `prettyDigits(1000000)`     | `'1 M'`     |
| `0.0004356` | `prettyDigits(0.0004356)`  | `'0.0004'`  |
| `100`       | `prettyDigits(100,{units:['b']})`   | `'100 b'`   |
| `-1250`     | `prettyDigits(-1250,{precision: 2})` | `'-1.25 K'` |

## Useage

```javascript
  import {prettyDigits} from 'prettyDigits'
  //or
  const {prettyDigits} = require('prettyDigits');

  prettyDigits(3500); // '4 K'

  prettyDigits(1293943, {precision: 3, tolowercase: true}) // '1.294 m'

  prettyDigits(-12345, {space: false, units: ['b','kb','mb','gb','tb']}) // '-12kb'

  prettyDigits(0.005431351234, {precision: 2}) // '0.00543'

  prettyDigits(0.000000765) // '7.65e-7' also applies for negative numbers
```
Numbers that are lower than 1e-7 get a scientific notion string returned.
## Options

| Name          | Type      | Default Values         | Description                                  |
|---------------|-----------|------------------------|----------------------------------------------|
| `precision`   | `number`  | `0`                    | Number of decimal places to use. If the number is between 1 and 0 the precision starts at where the trailing zeros end. Eg `prettyDigits(0.0053,{precision: 0})` = `'0.005'`             |
| `tolowercase` | `boolean` | `false`                | Change abbreviation to lower case            |
| `space`       | `boolean` | `true`                 | Adds a space between abbreviation and number |
| `units`       | `Array`   | `["","K","M","B","T"]` | Change the units to your own custom ones     |

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