RepoPilot

What units (KB, MB, GB...) does this support?

About sindresorhus/pretty-bytes · 2 messages · last activity 8/1/2026

Question

What units (KB, MB, GB...) does this support?

RepoPilot

The pretty-bytes library supports multiple sets of units depending on the options you use:

Standard byte units (SI Prefix) — used by default: B, kB, MB, GB, TB, PB, EB, ZB, YB [index.js:L1-L9]

Binary byte units — when binary: true option is set: B, KiB, MiB, GiB, TiB, PiB, EiB, ZiB, YiB [index.js:L11-L19]

Bit units (SI Prefix) — when bits: true option is set: b, kbit, Mbit, Gbit, Tbit, Pbit, Ebit, Zbit, Ybit [index.js:L21-L29]

Binary bit units — when both bits: true and binary: true options are set: b, kibit, Mibit, Gibit, Tibit, Pibit, Eibit, Zibit, Yibit [index.js:L31-L39]

The function automatically selects the appropriate unit array based on your options and scales the input number accordingly [index.js:L139-L141].

FOLLOW_UPS:

  • How does the library choose which unit to display?
  • What's the difference between binary and SI prefix units?
  • Can I customize the unit strings?

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.