RepoPilot

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

About sindresorhus/pretty-bytes · 2 messages · last activity 7/20/2026

Question

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

RepoPilot

Yes, there is. The bits option allows you to format the number as bits instead of bytes [index.d.ts:L23-L32].

When you set bits: true, the output will display bit units instead of byte units. For example [index.d.ts:L28-L31]:

import prettyBytes from 'pretty-bytes';

prettyBytes(1337, {bits: true});
//=> '1.34 kbit'

This option defaults to false [index.d.ts:L25], so by default the library formats numbers as bytes. The bits option is useful when referring to bit rates or other bit-based measurements.

FOLLOW_UPS:

  • How do I use binary prefix instead of SI prefix?
  • What other formatting options are available?
  • Can I combine bits with other options like signed?

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.