RepoPilot

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

About sindresorhus/pretty-bytes · 2 messages · last activity 6/29/2026

Question

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

RepoPilot

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

Standard (SI Prefix) - Base-10: B, kB, MB, GB, TB, PB, EB, ZB, YB [index.js:L1-L9]

Binary Prefix - Base-2: B, KiB, MiB, GiB, TiB, PiB, EiB, ZiB, YiB [index.js:L11-L19]

Bits (SI Prefix) - Base-10: b, kbit, Mbit, Gbit, Tbit, Pbit, Ebit, Zbit, Ybit [index.js:L21-L29]

Bits (Binary Prefix) - Base-2: b, kibit, Mibit, Gibit, Tibit, Pibit, Eibit, Zibit, Yibit [index.js:L31-L39]

You control which system is used with the binary and bits options:

  • By default, it uses SI Prefix bytes (kB, MB, GB, etc.)
  • Set {binary: true} to use Binary Prefix (KiB, MiB, GiB, etc.)
  • Set {bits: true} to display bits instead of bytes

FOLLOW_UPS:

  • How does the binary option differ from SI prefix?
  • Can I customize the unit labels?
  • What input values trigger each unit?

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.