Question
Can I get binary (KiB, MiB) units instead of decimal? How?
About sindresorhus/pretty-bytes · 2 messages · last activity 7/6/2026
Can I get binary (KiB, MiB) units instead of decimal? How?
Yes, you can use the binary option to get binary units (KiB, MiB, etc.) instead of decimal units (kB, MB, etc.).
Set binary: true in the options object:
import prettyBytes from 'pretty-bytes';
prettyBytes(1024, {binary: true});
//=> '1 KiB'
When you enable the binary option, the library uses the Binary Prefix standard instead of the SI Prefix. This means:
According to the README, this is useful for presenting memory amounts, though it should not be used for file sizes.
FOLLOW_UPS:
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.