File Size Unit Conversion Table
A quick conversion chart for B, KB, KiB, MB, MiB, GB and GiB — for writing code, checking configuration values and designing tests.
SI units (decimal) versus IEC units (binary)
File sizes are expressed with two different families of units: decimal units from the International System of Units (SI), and binary units defined by the IEC. Confusing MB with MiB is a common reason boundary tests fail.
| SI unit | Name | Bytes | IEC unit | Name | Bytes | Difference |
|---|---|---|---|---|---|---|
| KB | Kilobyte | 1,000 | KiB | Kibibyte | 1,024 | +2.4% |
| MB | Megabyte | 1,000,000 | MiB | Mebibyte | 1,048,576 | +4.86% |
| GB | Gigabyte | 1,000,000,000 | GiB | Gibibyte | 1,073,741,824 | +7.37% |
| TB | Terabyte | 1,000,000,000,000 | TiB | Tebibyte | 1,099,511,627,776 | +9.95% |
MB to bytes conversion table
| MB (decimal) | Bytes | MiB (binary) | Bytes |
|---|---|---|---|
| 0.1 MB | 100,000 B | 0.1 MiB | 104,858 B |
| 0.5 MB | 500,000 B | 0.5 MiB | 524,288 B |
| 1 MB | 1,000,000 B | 1 MiB | 1,048,576 B |
| 2 MB | 2,000,000 B | 2 MiB | 2,097,152 B |
| 5 MB | 5,000,000 B | 5 MiB | 5,242,880 B |
| 10 MB | 10,000,000 B | 10 MiB | 10,485,760 B |
| 20 MB | 20,000,000 B | 20 MiB | 20,971,520 B |
| 25 MB | 25,000,000 B | 25 MiB | 26,214,400 B |
| 50 MB | 50,000,000 B | 50 MiB | 52,428,800 B |
| 100 MB | 100,000,000 B | 100 MiB | 104,857,600 B |
| 256 MB | 256,000,000 B | 256 MiB | 268,435,456 B |
| 512 MB | 512,000,000 B | 512 MiB | 536,870,912 B |
| 1 GB | 1,000,000,000 B | 1 GiB | 1,073,741,824 B |
How major services and tools interpret these units
| Service / setting | Notation | Actual interpretation | Example |
|---|---|---|---|
| PHP(php.ini) | M | MiB (binary) | 10M = 10,485,760 B |
| Nginx(client_max_body_size) | m | MiB (binary) | 10m = 10,485,760 B |
| Apache(LimitRequestBody) | Bytes | Bytes (literal) | 10485760 = 10 MiB |
| Windows Explorer | Shows MB | Calculated as MiB (binary) | 「9.99 MB」= 10,476,544 B |
| macOS Finder | Shows MB | MB (decimal) | 「10 MB」= 10,000,000 B |
| Linux(ls -lh) | M | MiB (binary) | 10M = 10 MiB |
| Gmail attachment limit | 25 MB | MB (decimal) | 25,000,000 B |
| AWS S3 console | Shows MiB | MiB (binary) | As displayed |
Formula
// Conversion helpers in JavaScript
const UNITS = {
// SI(10進数)
KB: 1_000,
MB: 1_000_000,
GB: 1_000_000_000,
TB: 1_000_000_000_000,
// IEC(2進数)
KiB: 1_024,
MiB: 1_048_576,
GiB: 1_073_741_824,
TiB: 1_099_511_627_776,
};
const toBytes = (value, unit) => value * UNITS[unit];
const fromBytes = (bytes, unit) => bytes / UNITS[unit];
// Example: 10 MiB to bytes
console.log(toBytes(10, 'MiB')); // → 10485760
// Example: 10,000,000 bytes to MB
console.log(fromBytes(10_000_000, 'MB')); // → 10
console.log(fromBytes(10_000_000, 'MiB').toFixed(2)); // → 9.54
1_000, 'MB' => 1_000_000, 'GB' => 1_000_000_000,
'KiB' => 1_024, 'MiB' => 1_048_576, 'GiB' => 1_073_741_824,
];
return (int)($value * ($units[$unit] ?? 1));
}
echo toBytes(10, 'MiB'); // → 10485760
echo toBytes(25, 'MB'); // → 25000000
Matching boundary-test files
DevLab provides boundary-test files sized to the common upload limits. Pick the one that matches how the target system interprets the unit.
- Threshold test files — sets of three files sized just under, exactly at, and just over each limit