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/20/2026
The library supports multiple unit systems depending on the options you use:
For bytes (default): B, kB, MB, GB, TB, PB, EB, ZB, YB [index.js:L1-L10]
For binary bytes (when binary: true):
B, KiB, MiB, GiB, TiB, PiB, EiB, ZiB, YiB
[index.js:L12-L20]
For bits (when bits: true):
b, kbit, Mbit, Gbit, Tbit, Pbit, Ebit, Zbit, Ybit
[index.js:L22-L30]
For binary bits (when bits: true and binary: true):
b, kibit, Mibit, Gibit, Tibit, Pibit, Eibit, Zibit, Yibit
[index.js:L32-L40]
The key difference is that the default uses SI prefixes (base-10, dividing by 1000), while the binary option uses binary prefixes (base-2, dividing by 1024). The bits option switches between byte and bit units.
FOLLOW_UPS:
- What's the difference between SI and binary prefixes?
- How does the library choose which unit to display?
- Can you use bits and binary together?
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.