RepoPilot

What units (KB, MB, GB...) does this support?

About sindresorhus/pretty-bytes · 2 messages · last activity 5/25/2026

Question

What units (KB, MB, GB...) does this support?

RepoPilot

The pretty-bytes library supports multiple unit systems depending on the options you use:

Standard SI Units (bytes) — used by default: B, kB, MB, GB, TB, PB, EB, ZB, YB [index.js:L1-L10]

Binary Units (bytes) — when binary: true option is set: B, KiB, MiB, GiB, TiB, PiB, EiB, ZiB, YiB [index.js:L12-L20]

Bit Units (standard SI) — when bits: true option is set: b, kbit, Mbit, Gbit, Tbit, Pbit, Ebit, Zbit, Ybit [index.js:L22-L30]

Binary Bit Units — when both bits: true and binary: true options are set: b, kibit, Mibit, Gibit, Tibit, Pibit, Eibit, Zibit, Yibit [index.js:L32-L40]

The library goes up to Yottabyte/Yottalogical units, which is the largest standardized unit. The appropriate unit is automatically selected based on the magnitude of the number being formatted [index.js:L144-L146].

FOLLOW_UPS:

  • How does the library choose which unit to display?
  • Can you customize the decimal precision of output?
  • Does it support localized number formatting?

Want to ask your own question?

Open chat for sindresorhus/pretty-bytes

Public Q&A. Generated by RepoPilot from the actual source of sindresorhus/pretty-bytes. AI answers can be incomplete or stale — verify before relying on them.