RepoPilot

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

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

Question

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

RepoPilot

The pretty-bytes library supports multiple unit systems depending on the options you choose:

For bytes (default): Defined in [index.js:L1-L9], the BYTE_UNITS array supports: B, kB, MB, GB, TB, PB, EB, ZB, YB

For binary format (with binary: true option): Defined in [index.js:L11-L19], the BIBYTE_UNITS array supports: B, KiB, MiB, GiB, TiB, PiB, EiB, ZiB, YiB

For bits (with bits: true option): Defined in [index.js:L21-L29], the BIT_UNITS array supports: b, kbit, Mbit, Gbit, Tbit, Pbit, Ebit, Zbit, Ybit

For binary bits (with both bits: true and binary: true options): Defined in [index.js:L31-L39], the BIBIT_UNITS array supports: b, kibit, Mibit, Gibit, Tibit, Pibit, Eibit, Zibit, Yibit

The function automatically selects the appropriate unit based on the magnitude of the number being formatted [index.js:L153-L154].

FOLLOW_UPS:

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

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.