Bytes to Human Readable Converter
Convert bytes to human readable strings online. Supports SI (kB, MB) and binary (KiB, MiB) prefixes, bits mode, locale formatting, and reverse parsing.
About
File sizes reported by operating systems, APIs, and storage devices arrive as raw byte counts. Interpreting 1073741824 as 1 GiB (binary) or 1.07 GB (SI) requires selecting the correct base. Confusing the two produces errors up to 7.4% per order of magnitude. SI prefixes use powers of 103 (1 kB = 1000 B), while binary (IEC 60027-2) prefixes use powers of 210 (1 KiB = 1024 B). This tool converts raw byte or bit counts to properly formatted human-readable strings with full control over prefix system, locale, precision, and signedness. It also reverses the operation, parsing strings like 4.2 GB back to exact byte counts. The tool approximates formatting behavior equivalent to the pretty-bytes npm module. Note: locale formatting affects only the decimal separator, not the unit label.
Formulas
The conversion selects the largest unit whose magnitude does not exceed the absolute value. For SI (decimal) prefixes:
For binary (IEC) prefixes:
For bits mode, the input n (in bytes) is first multiplied by 8 before applying the same algorithm, and bit-suffixed units replace byte-suffixed ones. Where n = input byte count, unit = zero-indexed exponent selecting the prefix tier, and value = the displayed numeric portion. The default precision uses 3 significant digits via rounding. When minimumFractionDigits or maximumFractionDigits is specified, truncation replaces rounding to avoid counter-intuitive file-size displays (e.g. 1999 B displaying as 2.00 kB).
Reference Data
| SI Unit | Symbol | Bytes (10n) | Binary Unit | Symbol | Bytes (2n) | Difference |
|---|---|---|---|---|---|---|
| Byte | B | 1 | Byte | B | 1 | 0% |
| Kilobyte | kB | 103 = 1,000 | Kibibyte | KiB | 210 = 1,024 | 2.4% |
| Megabyte | MB | 106 = 1,000,000 | Mebibyte | MiB | 220 = 1,048,576 | 4.9% |
| Gigabyte | GB | 109 | Gibibyte | GiB | 230 = 1,073,741,824 | 7.4% |
| Terabyte | TB | 1012 | Tebibyte | TiB | 240 | 10.0% |
| Petabyte | PB | 1015 | Pebibyte | PiB | 250 | 12.6% |
| Exabyte | EB | 1018 | Exbibyte | EiB | 260 | 15.3% |
| Zettabyte | ZB | 1021 | Zebibyte | ZiB | 270 | 18.1% |
| Yottabyte | YB | 1024 | Yobibyte | YiB | 280 | 20.9% |
| Bit Equivalents | ||||||
| Bit | bit | 0.125 B | Bit | bit | 0.125 B | - |
| Kilobit | kbit | 125 B | Kibibit | Kibit | 128 B | 2.4% |
| Megabit | Mbit | 125,000 B | Mebibit | Mibit | 131,072 B | 4.9% |
| Gigabit | Gbit | 125,000,000 B | Gibibit | Gibit | 134,217,728 B | 7.4% |