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/8/2026
Based on the README excerpt provided, the repository data doesn't explicitly list all supported units. However, I can see from the examples that it supports at least:
- B (bytes) — shown in examples like
'100 B'and'+42 B' - kB (kilobytes) — shown in
'1.34 kB' - kbit (kilobits) — shown in
'1.34 kbit'when using thebitsoption - KiB (kibibytes) — shown in
'1 KiB'when using thebinaryoption
The README mentions the library uses base-10 (SI Prefix) by default, and supports Binary Prefix when the binary option is enabled. It likely supports the full range of SI prefixes (kB, MB, GB, TB, etc.) and binary prefixes (KiB, MiB, GiB, TiB, etc.), but the exact unit scaling isn't fully documented in the excerpt provided.
To see the complete list of supported units and their thresholds, I'd recommend checking the main implementation file directly (likely index.js or index.ts in the repository root).
FOLLOW_UPS:
- What are the exact unit thresholds for scaling?
- Does it support units larger than terabytes?
- How are units selected based on the input number?
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.