What units (KB, MB, GB...) does this support?
What units (KB, MB, GB...) does this support?
About sindresorhus/pretty-bytes · 2 messages · last activity 7/6/2026
The pretty-bytes library supports multiple sets of units depending on the options you use:
Standard Byte Units (SI Prefix, base-10): B, kB, MB, GB, TB, PB, EB, ZB, YB — defined in [index.js:L1-L9]
Binary Byte Units (Binary Prefix, base-2): B, KiB, MiB, GiB, TiB, PiB, EiB, ZiB, YiB — defined in [index.js:L11-L19]
Bit Units (SI Prefix): b, kbit, Mbit, Gbit, Tbit, Pbit, Ebit, Zbit, Ybit — defined in [index.js:L21-L29]
Binary Bit Units (Binary Prefix): b, kibit, Mibit, Gibit, Tibit, Pibit, Eibit, Zibit, Yibit — defined in [index.js:L31-L39]
Which unit set is used depends on the options passed to the function:
- Default: SI Prefix bytes (B, kB, MB, etc.)
- With
{binary: true}: Binary Prefix bytes (B, KiB, MiB, etc.) — useful for memory amounts - With
{bits: true}: SI Prefix bits (b, kbit, Mbit, etc.) - With
{bits: true, binary: true}: Binary Prefix bits (b, kibit, Mibit, etc.)
FOLLOW_UPS:
- How does the library choose which unit to display?
- What's the difference between SI and binary prefixes?
- Can you customize the unit labels?
Want to ask your own question?
Open chat for sindresorhus/pretty-bytesPublic 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.