Is there an option to display in bits instead of bytes?
Is there an option to display in bits instead of bytes?
About sindresorhus/pretty-bytes · 2 messages · last activity 7/13/2026
Yes, there is. The bits option allows you to format the number as bits instead of bytes.
According to [index.d.ts:L23-L31], the bits option is a boolean (default: false) that formats the number as bits instead of bytes. This can be useful when referring to bit rate.
Here's an example from the documentation [readme.md:L1-L9]:
import prettyBytes from 'pretty-bytes';
prettyBytes(1337, {bits: true});
//=> '1.34 kbit'
When this option is enabled, the output uses bit units (like kbit, Mbit, Gbit, etc.) instead of byte units (like kB, MB, GB, etc.). The available bit unit arrays are defined in [index.js:L27-L35] as BIT_UNITS and BIBIT_UNITS for binary prefix variants.
FOLLOW_UPS:
- What bit unit names are used in the library?
- Can you combine bits option with binary prefix?
- How are bit units different from byte 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.