Question
Is there an option to display in bits instead of bytes?
About sindresorhus/pretty-bytes · 2 messages · last activity 6/8/2026
Is there an option to display in bits instead of bytes?
Yes, there is. According to the README, the bits option allows you to format the number as bits instead of bytes.
Option details:
booleanfalseExample usage:
import prettyBytes from 'pretty-bytes';
prettyBytes(1337, {bits: true});
//=> '1.34 kbit'
This option is useful when referring to bit rates or other bit-based measurements. When enabled, the output will use "kbit" (kilobit), "Mbit" (megabit), etc. instead of the byte-based units like "kB" or "MB".
FOLLOW_UPS:
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.