RepoPilot

Is there an option to display in bits instead of bytes?

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

Question

Is there an option to display in bits instead of bytes?

RepoPilot

Yes, there is. According to the README, the bits option allows you to format the number as bits instead of bytes.

Option details:

  • Type: boolean
  • Default: false

Example 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:

  • What other formatting options are available?
  • How does the binary prefix option work?
  • Can I combine multiple options together?

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.