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/13/2026
The pretty-bytes library supports multiple unit systems depending on the options you use:
Byte Units (default) [index.js:L1-L9]:
- B, kB, MB, GB, TB, PB, EB, ZB, YB
Binary Byte Units (when binary: true) [index.js:L12-L20]:
- B, KiB, MiB, GiB, TiB, PiB, EiB, ZiB, YiB
Bit Units (when bits: true) [index.js:L23-L31]:
- b, kbit, Mbit, Gbit, Tbit, Pbit, Ebit, Zbit, Ybit
Binary Bit Units (when both bits: true and binary: true) [index.js:L34-L42]:
- b, kibit, Mibit, Gibit, Tibit, Pibit, Eibit, Zibit, Yibit
The choice of unit system is determined by the bits and binary options passed to the prettyBytes() function [index.js:L140-L142]. By default, it uses the base-10 byte units (SI prefix), which follows the kilobyte standard (1 kB = 1000 B) rather than the binary standard (1 KiB = 1024 B).
FOLLOW_UPS:
- What's the difference between bits and bytes options?
- How does the binary prefix work exactly?
- Can you show an example with binary units?
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.