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 8/1/2026
Question
RepoPilot
Yes, there is. The bits option allows you to format the number as bits instead of bytes.
According to the API documentation [index.d.ts:L23-L32], the bits option:
- Type:
boolean - Default:
false - Purpose: Format the number as bits instead of bytes, which can be useful when referring to bit rate.
Example usage:
prettyBytes(1337, {bits: true});
//=> '1.34 kbit'
When you enable this option, the output will use bit units (b, kbit, Mbit, Gbit, etc.) instead of byte units (B, kB, MB, GB, etc.). The implementation [index.js:L26-L32] handles this by selecting the appropriate unit array based on the bits and binary options.
FOLLOW_UPS:
- What unit strings are used for bits output?
- Can I combine bits option with binary prefix?
- How does the locale option affect bit formatting?
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.