Skip to content

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 (decimal) vs IEC (binary) — gap grows per unit KB / KiB KB = 1,000 B KiB = 1,024 B (+2.4%) MB / MiB MB = 1,000,000 B MiB = 1,048,576 B (+4.9%) GB / GiB GB = 10^9 B GiB = 2^30 B (+7.4%) OS often labels GiB as "GB"
Diagram: gap between 10^3 and 2^10 widens per unit

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 unitNameBytes IEC unitNameBytes Difference
KBKilobyte1,000 KiBKibibyte1,024 +2.4%
MBMegabyte1,000,000 MiBMebibyte1,048,576 +4.86%
GBGigabyte1,000,000,000 GiBGibibyte1,073,741,824 +7.37%
TBTerabyte1,000,000,000,000 TiBTebibyte1,099,511,627,776 +9.95%

MB to bytes conversion table

MB (decimal)BytesMiB (binary)Bytes
0.1 MB100,000 B0.1 MiB104,858 B
0.5 MB500,000 B0.5 MiB524,288 B
1 MB1,000,000 B1 MiB1,048,576 B
2 MB2,000,000 B2 MiB2,097,152 B
5 MB5,000,000 B5 MiB5,242,880 B
10 MB10,000,000 B10 MiB10,485,760 B
20 MB20,000,000 B20 MiB20,971,520 B
25 MB25,000,000 B25 MiB26,214,400 B
50 MB50,000,000 B50 MiB52,428,800 B
100 MB100,000,000 B100 MiB104,857,600 B
256 MB256,000,000 B256 MiB268,435,456 B
512 MB512,000,000 B512 MiB536,870,912 B
1 GB1,000,000,000 B1 GiB1,073,741,824 B

How major services and tools interpret these units

Service / settingNotationActual interpretationExample
PHP(php.ini)MMiB (binary)10M = 10,485,760 B
Nginx(client_max_body_size)mMiB (binary)10m = 10,485,760 B
Apache(LimitRequestBody)BytesBytes (literal)10485760 = 10 MiB
Windows ExplorerShows MBCalculated as MiB (binary)「9.99 MB」= 10,476,544 B
macOS FinderShows MBMB (decimal)「10 MB」= 10,000,000 B
Linux(ls -lh)MMiB (binary)10M = 10 MiB
Gmail attachment limit25 MBMB (decimal)25,000,000 B
AWS S3 consoleShows MiBMiB (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

❓ Frequently Asked Questions

Is 1 GB 1000 MB or 1024 MB?
As an SI prefix, GB means 1000 MB. The value 1024 MB is a GiB, a gibibyte, from the binary prefixes. Storage vendors label capacity in SI while Windows shows the GiB figure labelled GB, which is why a 500 GB drive reads as 465 GB. The gap is about 7% and widens in the terabyte range.
Which unit should I use when setting an upload limit?
Match whatever the software you are configuring interprets. PHP's upload_max_filesize and nginx's client_max_body_size both treat M as 1024×1024, so they are effectively MiB. Meanwhile a user told "up to 10 MB" will read that as 10,000,000 bytes. Test with a file sitting exactly on the boundary and make the wording and the implementation agree.
How does Mbps for network speed relate to MB of file size?
Lower-case b is bits and upper-case B is bytes; one byte is eight bits. A 100 Mbps link can carry about 12.5 MB per second in theory, and roughly a tenth less in practice once protocol overhead is counted. A 100 MB file therefore takes eight seconds at the ideal rate and nine to ten in reality.