KB vs KiB: SI prefixes, binary prefixes, and why the confusion persists
“Is 1 KB equal to 1000 bytes or 1024 bytes?” is a question even technical people answer differently. Historical conventions and industry-specific habits keep both interpretations alive. This article walks through the muddle and IEC’s official resolution.
SI prefixes: powers of 10
The International System of Units (SI) defines prefixes as powers of 10:
| Prefix | Symbol | Value |
|---|---|---|
| kilo | k | 10^3 = 1,000 |
| mega | M | 10^6 = 1,000,000 |
| giga | G | 10^9 |
| tera | T | 10^12 |
| peta | P | 10^15 |
Nobody questions “1 km = 1000 m” or “1 kg = 1000 g”. By the same rule, 1 KB should be 1000 bytes.
Binary prefixes: powers of 2
In computing, memory and OS storage figures are often powers of 2:
| Prefix (informal) | Value | Drift from SI |
|---|---|---|
| 1 KB | 1024 = 2^10 bytes | +2.4% |
| 1 MB | 1,048,576 = 2^20 bytes | +4.9% |
| 1 GB | 2^30 ≈ 1.074 × 10^9 bytes | +7.4% |
| 1 TB | 2^40 ≈ 1.100 × 10^12 bytes | +10.0% |
| 1 PB | 2^50 ≈ 1.126 × 10^15 bytes | +12.6% |
Because memory is naturally sized in powers of 2, the convention “1 KB = 1024 bytes” arose. Reusing the SI symbol KB for a different value is the root of the confusion. The drift is small at the kilo scale but exceeds 10% by tera.
IEC’s resolution: KiB, MiB, GiB
To resolve this, the IEC defined binary prefixes with distinct symbols in 1998:
| Prefix | Symbol | Value |
|---|---|---|
| kibi | Ki | 2^10 = 1,024 |
| mebi | Mi | 2^20 = 1,048,576 |
| gibi | Gi | 2^30 |
| tebi | Ti | 2^40 |
| pebi | Pi | 2^50 |
The rule is simple:
- KB = 1000 bytes (SI, powers of 10)
- KiB = 1024 bytes (IEC, powers of 2)
Spoken as “kibibyte”, “mebibyte”, and so on. Linux and macOS df / du support IEC notation via -h.
When you display memory or storage capacity, KiB / MiB / GiB is the strictly correct notation.
Industry conventions diverge
Even after the spec, different industries kept their habits.
HDDs and SSDs: SI (1 GB = 10^9 bytes)
Storage manufacturers have always used SI:
- A “1 TB SSD” advertises 1,000,000,000,000 bytes (10^12).
- The OS reports “931 GB” (actually 931 GiB ≈ 1 TB SI).
The recurring “I bought 1 TB but I only see 931 GB” complaint isn’t a fraud — it’s the manufacturer using SI and the OS using binary.
Memory (RAM): binary (1 GB = 2^30 bytes)
DRAM chip capacities are powers of 2 by design, so what should be GiB gets called GB by industry convention.
- A “16 GB DDR5” stick is actually 16 GiB = 17.18 GB in SI.
When you see “GB” on RAM, 99% of the time it means GiB.
Network bandwidth: SI, in bits
Network bandwidth is bps (bits per second) in SI:
- “1 Gbps” = 10^9 bits/second ≈ 125 MB/s (in bytes).
“1 Gbps means a 1 GB file in 8 seconds” is the kind of arithmetic that tripps people up:
- Bandwidth: 1 Gbps = 10^9 bits/s = 1.25 × 10^8 bytes/s.
- File: 1 GB (if your OS shows GiB) = 2^30 ≈ 1.07 × 10^9 bytes.
- Time: 1.07 × 10^9 / 1.25 × 10^8 ≈ 8.6 s.
Also, bits (b) ≠ bytes (B) — they differ by a factor of 8. Mixing Gbps with GB/s lands you off by an order of magnitude.
CPU clocks: SI (1 GHz = 10^9 Hz)
CPU clocks are pure frequency, so SI applies cleanly. No confusion here.
Where to be careful in code
1. File size formatting
User-facing strings prioritize readability, so “KB / MB / GB” remain common over “KiB / MiB / GiB”. Pick a base internally and document it:
function formatBytes(bytes, useBinary = true) {
const base = useBinary ? 1024 : 1000;
const prefixes = useBinary ? ['B', 'KiB', 'MiB', 'GiB'] : ['B', 'KB', 'MB', 'GB'];
let i = 0;
while (bytes >= base && i < prefixes.length - 1) {
bytes /= base;
i++;
}
return `${bytes.toFixed(1)} ${prefixes[i]}`;
} 2. Storage capacity planning
For database capacity planning, account for the SI/binary gap:
- “100 GB of data” can be 100 GiB or 100 GB (SI), differing by ~10 GB.
- The gap grows with scale.
3. Log output
Server logs are stricter when they use IEC (GiB), but many sites stick with GB. Document which convention your operations team uses.
4. API responses
When returning a size from an API, return raw bytes as an integer. Let the consumer format:
{ "fileSize": 5368709120 } // 5 GiB / ~5.37 GB A string like "5 GB" forces every consumer to parse it.
Summary
- SI — powers of 10:
k = 10^3,M = 10^6. - IEC — powers of 2:
Ki = 2^10,Mi = 2^20. - HDDs / SSDs — SI.
- RAM — binary, but usually labeled “GB” anyway.
- Networks — SI, in bits.
- Bit vs Byte — factor of 8 (lowercase
bvs uppercaseB).
In technical writing, IEC notation (KiB, MiB, GiB) is strictly correct. For end users, KB/MB/GB with binary values is more familiar. The pragmatic balance is to pick one and stick with it.
To check conversions across these units, the byte converter on this site moves between KB, KiB, MB, MiB, etc. side by side — handy when you want to see the SI/IEC drift directly.