Convert bytes to a human readable string with support for bits, binary prefixes, localization, and fixed-width formatting.
pretty-bytes is a JavaScript utility that converts numeric byte values into human-readable strings like '1.34 kB' or '1 KiB'. It solves the problem of presenting raw byte counts in a format that's easily understandable by users, with support for different unit systems and localization.
Developers building applications that need to display file sizes, memory usage, network transfer rates, or any byte-based metrics in a user interface.
Developers choose pretty-bytes for its robust feature set—including bit formatting, binary/SI prefixes, localization, and fixed-width alignment—coupled with sensible defaults that avoid common pitfalls like misleading rounding.
Convert bytes to a human readable string: 1337 → 1.34 kB
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Supports both SI (base-10) and binary (base-2) prefixes with clear documentation, making it adaptable for file sizes or memory reporting as needed.
Allows localization of number and decimal separators using BCP 47 language tags, improving usability in international applications without extra setup.
Uses truncation instead of rounding when minimum or maximum fraction digits are set, preventing misleading file size displays that can occur with standard rounding.
Provides fixed-width output option to right-align strings, essential for creating neatly formatted tables or progress bars without manual padding.
Can format numbers as bits or bytes, extending its utility beyond file sizes to bit rate displays and network speed metrics with a simple option.
Only localizes number and decimal separators; unit titles (e.g., 'kB') remain in English, which may not suffice for fully internationalized user interfaces.
Defaults to SI prefixes, which can confuse users in contexts where binary prefixes are standard (e.g., memory reporting), requiring explicit configuration and potential user education.
As a Node.js module, it adds overhead for browser projects and isn't suitable for non-JavaScript environments, limiting its use in multi-platform or lightweight applications.