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 5/18/2026
Question
RepoPilot
Yes, there is a bits option that allows you to display the number as bits instead of bytes.
According to [index.d.ts:L24-L35], the bits option is a boolean with a default value of false. When set to true, it formats the number as bits instead of bytes, which can be useful when referring to bit rate.
Here's an example from [readme.md:L66-L70]:
import prettyBytes from 'pretty-bytes';
prettyBytes(1337, {bits: true});
//=> '1.34 kbit'
So when you pass {bits: true}, the output will use the unit "kbit" (kilobits) instead of "kB" (kilobytes).
FOLLOW_UPS:
- What's the difference between binary and SI prefix?
- How do you localize the output to different languages?
- Can you control the number of decimal places shown?
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.