RepoPilot

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

About sindresorhus/pretty-bytes · 2 messages · last activity 7/27/2026

Question

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

RepoPilot

The library supports multiple unit systems depending on the options you use:

Standard (base-10) byte units [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

Standard (base-10) bit units (when bits: true) [index.js:L23-L31]:

  • b, kbit, Mbit, Gbit, Tbit, Pbit, Ebit, Zbit, Ybit

Binary bit units (when bits: true, binary: true) [index.js:L34-L42]:

  • b, kibit, Mibit, Gibit, Tibit, Pibit, Eibit, Zibit, Yibit

By default, the library uses base-10 byte units (B through YB). The choice of unit system is determined automatically based on the input value and the selected options—the library will use the most appropriate unit to keep the number readable (typically scaled to 3 significant figures).

FOLLOW_UPS:

  • How does the library choose which unit to display?
  • What's the difference between binary and standard units?
  • Can I format numbers less than 1 byte?

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.