# bytes-formatter

> Bytes formatter module provides a function to format byte values into human-readable strings with appropriate units (bytes, KB, MB, GB, TB, PB).

Latest version **21.6.15** (published 2025-02-15) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install bytes-formatter
pnpm add bytes-formatter
yarn add bytes-formatter
bun add bytes-formatter
```

## Health

**Score 40/100 (D)** — status: maintenance-mode.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 21.6.15 |
| Published | 2025-02-15 |
| First published | 2021-06-20 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 14.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Author | Valentin Podkamennyi |
| Maintainers | vpodk, lizapodk |
| Keywords | bytes-formatter, byte-formatter, format-bytes, formatBytes, filesize, pretty-bytes |

## Links

- npm: https://www.npmjs.com/package/bytes-formatter
- Repository: https://github.com/vpodk/bytes-formatter
- Homepage: https://vpodk.com/bytes-formatter/
- Issues: https://github.com/vpodk/bytes-formatter/issues
- Funding: https://github.com/sponsors/vpodk
- npm.io page: https://npm.io/package/bytes-formatter

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 21.6.15 (latest) — 2025-02-15
- 21.6.14 — 2025-02-06
- 21.6.12 — 2021-08-26
- 21.6.11 — 2021-07-11
- 21.6.10 — 2021-06-28
- 21.6.9 — 2021-06-21
- 21.6.8 — 2021-06-21
- 21.6.7 — 2021-06-21
- 21.6.6 — 2021-06-21
- 21.6.5 — 2021-06-20
- 21.6.4 — 2021-06-20
- 21.6.3 — 2021-06-20
- 21.6.2 — 2021-06-20
- 21.6.1 — 2021-06-20
- 21.6.0 — 2021-06-20

## README

# Bytes Formatter [![Tweet](https://img.shields.io/twitter/url/http/shields.io.svg?style=social)](https://twitter.com/intent/tweet?text=Bytes%20formatter%20module.&url=https://github.com/vpodk/bytes-formatter&via=GitHub&hashtags=JavaScript,ECMAScript,ES6)

[![Build Status](https://github.com/vpodk/bytes-formatter/actions/workflows/npm-publish.yml/badge.svg)](https://github.com/vpodk/bytes-formatter/actions/workflows/npm-publish.yml) [![License](https://img.shields.io/:license-apache-blue.svg)](https://www.apache.org/licenses/LICENSE-2.0.html) [![NPM version](https://img.shields.io/npm/v/bytes-formatter.svg?style=flat)](https://npmjs.org/package/bytes-formatter) [![NPM downloads](https://img.shields.io/npm/dm/bytes-formatter.svg?style=flat)](https://npmjs.org/package/bytes-formatter)

Bytes formatter module provides a function to format byte values into human-readable strings with appropriate units (bytes, KB, MB, GB, TB, PB).

## Usage

```bash
npm install bytes-formatter
# Or
yarn add bytes-formatter
```

```js
import { formatBytes } from "bytes-formatter";

/**
 * Formats given <code>bytes</code> to human friendly format.
 * @param {number} bytes The bytes to be formatted.
 * @return {string} The formatted bytes as string.
 */
console.log(formatBytes(1000)); // "1000 bytes"
console.log(formatBytes(1024)); // "1.00 KB"
console.log(formatBytes(1000000)); // "976.56 KB"
console.log(formatBytes(2000000)); // "1.91 MB"
console.log(formatBytes(2000000000)); // "1.86 GB"
console.log(formatBytes(2000000000000)); // "1.82 TB"
console.log(formatBytes(Number.MAX_SAFE_INTEGER)); // "8.00 PB"
```

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