What units (KB, MB, GB...) does this support?
What units (KB, MB, GB...) does this support?
About sindresorhus/pretty-bytes · 2 messages · last activity 6/15/2026
The pretty-bytes library supports multiple sets of units depending on the options used:
Standard byte units (SI Prefix, default):
B, kB, MB, GB, TB, PB, EB, ZB, YB [index.js:L1-L9]
Binary byte units (when binary: true):
B, KiB, MiB, GiB, TiB, PiB, EiB, ZiB, YiB [index.js:L11-L19]
Bit units (when bits: true):
b, kbit, Mbit, Gbit, Tbit, Pbit, Ebit, Zbit, Ybit [index.js:L21-L29]
Binary bit units (when bits: true and binary: true):
b, kibit, Mibit, Gibit, Tibit, Pibit, Eibit, Zibit, Yibit [index.js:L31-L39]
By default, the library uses base-10 SI Prefix units (kilobyte, megabyte, etc.) rather than binary units (kibibyte, mebibyte, etc.).
FOLLOW_UPS:
- How does the binary option differ from standard units?
- Can you customize the unit names or abbreviations?
- What's the maximum unit the library can display?
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.