User Rating 0.0 โ˜…โ˜…โ˜…โ˜…โ˜…
Total Usage 0 times
Accepts integers, negatives, scientific notation (1e6). Separate multiple values with commas or newlines.
Quick test:
Is this tool helpful?

Your feedback helps us improve.

โ˜… โ˜… โ˜… โ˜… โ˜…

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.

bytes converter pretty bytes file size converter human readable bytes kB MB GB converter binary prefix SI prefix byte formatter

Formulas

The conversion selects the largest unit whose magnitude does not exceed the absolute value. For SI (decimal) prefixes:

unit = floor(log10(|n|)3)
value = n1000unit

For binary (IEC) prefixes:

unit = floor(log2(|n|)10)
value = n1024unit

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 UnitSymbolBytes (10n)Binary UnitSymbolBytes (2n)Difference
ByteB1ByteB10%
KilobytekB103 = 1,000KibibyteKiB210 = 1,0242.4%
MegabyteMB106 = 1,000,000MebibyteMiB220 = 1,048,5764.9%
GigabyteGB109GibibyteGiB230 = 1,073,741,8247.4%
TerabyteTB1012TebibyteTiB24010.0%
PetabytePB1015PebibytePiB25012.6%
ExabyteEB1018ExbibyteEiB26015.3%
ZettabyteZB1021ZebibyteZiB27018.1%
YottabyteYB1024YobibyteYiB28020.9%
Bit Equivalents
Bitbit0.125 BBitbit0.125 B -
Kilobitkbit125 BKibibitKibit128 B2.4%
MegabitMbit125,000 BMebibitMibit131,072 B4.9%
GigabitGbit125,000,000 BGibibitGibit134,217,728 B7.4%

Frequently Asked Questions

The lowercase "k" is the standardized SI prefix for kilo (10ยณ) as defined by the International Bureau of Weights and Measures (BIPM). Uppercase "K" in "KB" is technically non-standard and ambiguous - it could mean either 1000 or 1024 bytes depending on context. The IEC 60027-2 standard resolved this by reserving "Ki" (KiB) for the binary meaning (1024). This tool follows both standards precisely.
Use binary prefixes (KiB, MiB, GiB) when reporting RAM, cache sizes, or any memory-addressed value because hardware uses powers of 2. Use SI prefixes (kB, MB, GB) for storage capacity (as marketed by manufacturers), network transfer rates, and file sizes in most operating systems. Note: macOS and iOS switched to SI prefixes in 2009 (Snow Leopard). Windows still uses binary values but labels them with SI symbols (e.g., shows "GB" but means GiB), which is technically incorrect.
By default, the tool rounds to 3 significant digits (e.g., 1,536 B โ†’ 1.54 kB). However, when you explicitly set minimumFractionDigits or maximumFractionDigits, the tool switches from rounding to truncation. This prevents unintuitive results: with rounding, 1,999 B with maximumFractionDigits=2 would display as 2.00 kB (which looks like exactly 2000 bytes), but with truncation it correctly shows 1.99 kB. This matches the behavior of the pretty-bytes npm package.
Yes. Negative byte values represent deltas - a decrease in storage, data removed, or a size difference. The tool formats the absolute value normally and preserves the minus sign. With the "signed" option enabled, positive values also receive a "+" prefix for alignment in tables and logs, while exact zero gets a space prefix instead of "+" or "-" to maintain column width.
JavaScript's Number.MAX_SAFE_INTEGER is 2โตยณ โˆ’ 1 (9,007,199,254,740,991 bytes โ‰ˆ 8 PiB or 9 PB). Beyond this, floating-point precision degrades and results become unreliable. For values up to the yottabyte range (10ยฒโด), the tool uses standard floating-point arithmetic which introduces small rounding artifacts above the petabyte tier. For exact large-integer arithmetic, BigInt input is supported in the underlying algorithm.
Locale formatting changes the decimal separator (e.g., comma in German "de" locale: 1,34 kB). The fixed-width padding is applied after locale formatting, so the total visual width accounts for all characters including localized separators. If the locale introduces grouping separators (e.g., 1.000.000 in some locales), the output may exceed the fixedWidth target - in this case, no padding is applied and the full string is returned.
In SI mode (default), the base is 1000, not 1024. So 1024 รท 1000 = 1.024, rounded to 3 significant digits = 1.02 kB. If you want 1024 to display as exactly "1 KiB", enable the binary prefix option. This distinction matters: a "500 GB" hard drive marketed in SI actually holds 465 GiB when measured in binary. The 7.4% per-tier discrepancy compounds across magnitude orders.