What this bytes to MB calculator does
Paste a byte value from anywhere — a Python os.path.getsize() return, a JavaScript File.size property, a MySQL BLOB length, an HTTP Content-Length header, a log line, or a database dump — and this calculator converts it to megabytes under both standards at once. The decimal answer divides by 1,000,000; the binary answer divides by 1,048,576. The two are about 4.86 percent apart, and knowing which one you actually mean matters more often than most people realise.
What makes this page different from a generic byte converter is that it is aimed squarely at the audience that actually has byte values: developers and sysadmins. Every default in the tool reflects that. The initial byte value is 1048576 — the exact 2^20 power-of-two value that Python, JavaScript, PHP, and MySQL all recognise as "1 MB" internally. The quick-pick panel is packed with the byte values that appear in real code — 4194304, 10485760, 5242880, 26214400, 104857600. The reference tables below the tool list the exact byte counts behind every PHP, MySQL, PostgreSQL, and HTTP size limit you are likely to hit.
If you have a byte value and need to know what it means in MB, this is the fastest path. If you have a MB value and need the byte count for a config file, the reverse tabs and lookup tables handle that too.
How to use it
- Paste your byte value. Type or paste a byte count into the input field. The result updates as you type — no need to press a convert button.
- Or click a power-of-two quick-pick. The panel above the tool has the byte values that appear in real code — 1024, 1048576, 4194304, 5242880, 10485760, 26214400, 104857600. One click loads them.
- Or drop a file. Drag any file onto the dashed drop zone and the browser reads its exact byte count using the File API. Useful when you want to verify a file's size against a byte limit.
- Read both answers. The large number is the primary answer in the standard that matches your input. The line beneath shows the alternate standard so you can see exactly how far apart they are.
- Check the bit/byte visualizer. The panel below the result shows the same value in bits, bytes, KB (decimal and binary), and MB (decimal and binary). Useful when you are working at the boundary between bits and bytes — network throughput, storage, or memory allocation.
- Use the reference tables. If you are setting a PHP upload limit or checking a MySQL BLOB size, the tables below the tool list every common limit with its exact byte count.
- Swap direction if needed. The MB → Bytes tab flips the converter so you can start from a MB value and find the byte count for your config file.
Why most byte values you see in code are powers of two
If you have spent any time in a codebase that handles file sizes, uploads, or memory, you have noticed something: the byte values are almost always suspiciously round in binary but messy in decimal. Values like 4,194,304 — which looks arbitrary in decimal — turn out to be exactly 2^22. Values like 10,485,760 are exactly 10 × 2^20. And the reason is simple: computers address memory in binary.
A system with N address lines can address 2^N unique bytes. Twenty address lines give you 1,048,576 bytes. Thirty give you 1,073,741,824 — one gibibyte. Because the underlying hardware is binary, the operating systems and programming languages that run on top of it inherit those round numbers. When a language designer writes "default buffer size: 4 MB", they almost certainly mean 4 × 2^20 = 4,194,304 bytes, not 4,000,000.
That is why the byte values in your code look the way they do. Here are the ones that come up most often:
| Power of two | Bytes | Why it matters |
|---|---|---|
| 2^10 | 1,024 | 1 KiB — the base binary block size |
| 2^16 | 65,536 | MySQL BLOB max, TCP window sizes, some hardware buffers |
| 2^20 | 1,048,576 | 1 MiB — Python's default file-size cutoff, MySQL TEXT column limit |
| 2^24 | 16,777,216 | 16 MiB — WhatsApp media, PHP's default max in many hosts, MySQL MEDIUMBLOB |
| 2^27 | 134,217,728 | 128 MiB — default PHP memory_limit for many installs |
| 2^30 | 1,073,741,824 | 1 GiB — the 32-bit address limit |
| 2^31 | 2,147,483,648 | 2 GiB — the classic signed 32-bit integer limit; breaks many older file-size APIs |
| 2^32 | 4,294,967,296 | 4 GiB — the unsigned 32-bit ceiling; MySQL LONGBLOB max is 2^32 - 1 |
| 2^40 | 1,099,511,627,776 | 1 TiB — the classic binary terabyte |
The practical upshot: when you see a byte value in code that looks suspiciously like 4,194,304 or 268,435,456, it is almost certainly a power of two. Divide by 1,048,576 to get the exact mebibyte count — 4 MiB or 256 MiB respectively — and you will match the intent of the original author. Divide by 1,000,000 instead and you get a slightly different number (4.194304 MB) that will not match any assert statement.
Bits, bytes, and the factor-of-8 trap
The single most common source of bugs in network code is forgetting that a byte is 8 bits. Every byte count has a matching bit count — just multiply by 8 — and every bit rate has a matching byte rate — divide by 8. This matters every time you compare a network throughput figure against a file size.
- A 100 Mbps internet connection downloads 12.5 MB per second, not 100. Divide the Mbps figure by 8 to get MB/s.
- A 1 Gbps fibre connection downloads 125 MB per second.
- A 10 Gbps datacentre link transfers 1,250 MB per second — a 1 TB file takes about 14 minutes at sustained throughput.
- A 25 Mbps upload speed sends 3.125 MB per second — a 1 GB backup uploads in about 5 minutes 20 seconds.
The bits-vs-bytes distinction also shows up in storage calculations. RAM is measured in bytes, but RAM chips are physically built as arrays of bits, and their internal bandwidth is quoted in bits per second. When you see "DDR4-3200", the "3200" refers to 3,200 million transfers per second — but each transfer moves 8 bytes on a standard 64-bit memory bus, so the effective bandwidth is 25,600 MB/s. The factor of 8 is everywhere once you start looking.
PHP, MySQL, and HTTP — the byte limits that actually break things
Most byte-to-MB conversions in a developer's life come from hitting a size limit and needing to know what the number actually means. Here are the ones that come up most, with their exact byte counts.
PHP upload and memory limits
PHP uses the shorthand suffixes K, M, and G in its php.ini file, and those suffixes are binary — M means 1,048,576 bytes, not 1,000,000. So the following are the exact byte counts behind the common settings:
upload_max_filesize = 2Mmeans 2,097,152 bytes (2 MiB)upload_max_filesize = 8Mmeans 8,388,608 bytes (8 MiB)upload_max_filesize = 10Mmeans 10,485,760 bytes (10 MiB)post_max_size = 8Mmeans 8,388,608 bytes — and it must always be ≥ upload_max_filesizememory_limit = 128Mmeans 134,217,728 bytes (128 MiB)memory_limit = 256Mmeans 268,435,456 bytes (256 MiB)
The classic WordPress problem — "the uploaded file exceeds the upload_max_filesize directive in php.ini" — happens when a user tries to upload a file whose byte count exceeds the configured limit. Knowing the exact byte count of the limit is the difference between a five-minute fix and an hour of debugging.
MySQL BLOB and TEXT limits
MySQL has four BLOB sizes and four matching TEXT sizes, and each one has a hard byte ceiling imposed by the column type:
- TINYBLOB / TINYTEXT — 255 bytes (2^8 - 1)
- BLOB / TEXT — 65,535 bytes (2^16 - 1)
- MEDIUMBLOB / MEDIUMTEXT — 16,777,215 bytes (2^24 - 1)
- LONGBLOB / LONGTEXT — 4,294,967,295 bytes (2^32 - 1)
The -1 in each of those formulas is why MySQL's BLOB limits are one byte less than the corresponding power of two. A BLOB column can hold up to 65,535 bytes, not 65,536, because MySQL reserves one value of the byte count for NULL handling.
HTTP and URL limits
- HTTP header size — most servers reject requests with total headers over 8 KB (8,192 bytes). Nginx defaults to
large_client_header_buffers 4 8k; Apache defaults to 8,190 bytes per header. - URL length — most modern browsers accept URLs up to about 2,000 characters, though the actual limit depends on the browser and the server. Apache defaults to 8,177 characters; IIS defaults to 16,384.
- POST body size — set by the server, not by HTTP itself. Nginx defaults to
client_max_body_size 1m(1 MiB); Apache is usually configured in PHP viapost_max_size.
Bytes to MB in Python, JavaScript, PHP, and SQL
Different languages have different conventions for byte-to-MB conversion, and getting it wrong can cause bugs that only surface at specific file sizes. Here is the reference for the languages you are most likely to be working in.
| Language | Decimal conversion | Binary conversion | Which one is common |
|---|---|---|---|
| Python | bytes / 1_000_000 | bytes / 1_048_576 | Binary, labelled as "MB" (e.g. humanize, tqdm) |
| JavaScript | bytes / 1_000_000 | bytes / 1_048_576 | Binary for File.size display |
| PHP | bytes / 1000000 | bytes / 1048576 | Binary for ini_get('upload_max_filesize') |
| Java | bytes / 1_000_000L | bytes / 1_048_576L | Binary for File.length() display |
| Go | bytes / 1e6 | bytes / 1048576 | Binary in most logging libraries |
| C#/.NET | bytes / 1_000_000D | bytes / 1_048_576D | Binary in System.IO file size display |
| SQL (MySQL) | bytes / 1000000 | bytes / 1048576 | Binary for LENGTH() on BLOB columns |
In every one of those languages, the safer choice for user-facing file-size display is the binary conversion (÷ 1,048,576) with an "MB" label. That matches what Windows File Explorer and macOS Finder show. If you are writing to a spec that says "megabytes" in the SI sense — a drive label, a cloud storage quota, a mobile data plan — use the decimal conversion instead.
Where bytes to MB conversion actually matters
- Debugging an upload failure. When a user's upload fails with a size-limit error, the exact byte count tells you whether the file exceeds the limit by 100 bytes or 100 MB — a very different fix.
- Configuring PHP limits. Setting
upload_max_filesizerequires knowing the exact byte count behind the "M" suffix. - Writing a size-limit check in code. If your API caps uploads at 10 MB, do you mean 10,000,000 bytes or 10,485,760 bytes? The answer affects which files are accepted.
- Testing size limits in unit tests. Assertions on file size need to match the exact binary value your code uses, not a decimal approximation.
- Reading a Content-Length header. HTTP responses report sizes in bytes; you usually want to know if that is 1 MB or 10 MB.
- Analyzing log files. Log rotation thresholds, request size limits, and error thresholds are all written in bytes internally.
- Sizing a database column. Choosing between BLOB and MEDIUMBLOB depends on knowing the byte count of your typical data.
- Estimating transfer time. A network throughput figure in bits per second divided by 8 gives bytes per second; that divided into a file size in bytes gives seconds.
- Comparing cloud storage bills. AWS S3, Azure Blob, and Backblaze all bill in decimal GB — so a "1 GB" file in your local Python code is not the same as a "1 GB" file in S3's billing.
Common mistakes and how to avoid them
- Mixing binary and decimal within a calculation. If you read a file size in binary from Windows and then compute a percentage against a decimal GB quota, the answer will be off by about 7 percent. Pick one standard and stick to it.
- Assuming 1 MB = 1,000,000 bytes in code. Almost every programming environment uses the binary value internally, even when the label says "MB". Defaulting to 1,000,000 will cause silent bugs when you compare against a real file size.
- Confusing bytes and bits. Network speeds are in bits per second. File sizes are in bytes. A 100 Mbps connection downloads 12.5 MB per second, not 100. Always divide by 8.
- Forgetting that PHP's ini suffixes are binary.
upload_max_filesize = 10Mmeans 10,485,760 bytes, not 10,000,000. If you write a client-side file-size check that uses the decimal value, it will reject files that the server would actually accept. - Assuming BLOB limits are power-of-two. MySQL's BLOB maxes are 2^N minus 1, not 2^N, because one byte count value is reserved. BLOB holds 65,535 bytes, not 65,536.
- Trusting a URL bar byte count. Modern browsers do not display byte counts in the URL bar, but many browser extensions do, and they disagree on which standard to use. Always check the tool's own documentation.
- Using the same conversion for both file sizes and network data. File sizes are bytes; network throughput is bits. If you confuse the two, you will be off by a factor of 8.
- Rounding too early. If you are chaining conversions — bytes → KB → MB → GB — do the full multiplication or division in a single step and round at the end. Rounding at each stage compounds the error.
- Assuming the byte count is always exact. Filesystem metadata, compression, and encoding can all change the effective size. A 1,048,576-byte file on disk might take 1,052,672 bytes of actual disk space due to block rounding.
Privacy and data handling
Every calculation happens inside your browser. Nothing you type is uploaded, logged, cached, or stored on any server. If you drop a file onto the drop zone, the browser reads only the file's .size property — a single integer the operating system already knows. The file's contents are never opened, decoded, or sent anywhere. Recent values are stored only in your browser's local storage so the tool can offer them back to you, and can be cleared with the button on the page. There is no account, no login, and no network request after the page loads.
Limitations to be aware of
- The tool cannot detect which standard your source used. If you paste a value from a Windows File Explorer panel labelled "MB", that number is a binary MiB in disguise. Use the MiB input unit to be exact.
- Display values are shown with up to 6 decimal places. For byte values below 1 MB, more digits may be needed — use the exact byte count or the raw division for full precision.
- The bit/byte visualizer assumes standard 8-bit bytes. Some legacy systems use non-standard byte sizes (rare, but they exist in aerospace and industrial contexts).
- The programming language reference assumes the standard library conventions. Some third-party libraries deviate — always check the documentation for the specific library you use.
- The file drop zone reads size only. It does not open, preview, edit, convert, or process the file itself.
- On rare occasions — iCloud "optimized storage" placeholders, OneDrive "files on-demand" items — the size the browser reports is the placeholder size, not the eventual downloaded size.
- History is per-browser. It does not sync across devices, and clearing your browser's site data will wipe it.
Frequently asked questions
How do I convert bytes to MB?
Divide the number of bytes by 1,000,000 for the decimal (SI) answer, or by 1,048,576 for the binary (IEC) answer. For example, 5,242,880 bytes ÷ 1,048,576 = 5 MiB binary; 5,242,880 bytes ÷ 1,000,000 = 5.24288 MB decimal.
How many bytes in a megabyte?
1 MB = 1,000,000 bytes in the decimal (SI) standard used by storage manufacturers, ISPs, and cloud platforms. 1 MiB = 1,048,576 bytes in the binary (IEC) standard that Windows File Explorer, macOS Finder, and most programming languages use internally.
What is 1048576 bytes in MB?
1,048,576 bytes is exactly 1 MiB (binary) and 1.048576 MB (decimal). The value 1,048,576 is 2^20, which is why it is the most common byte value in programming — it represents exactly one mebibyte.
What is 4194304 bytes in MB?
4,194,304 bytes is exactly 4 MiB (binary) and 4.194304 MB (decimal). The value 4,194,304 is 2^22 — the classic 4 MiB boundary that appears in PHP upload limits, memory allocations, and file-system blocks.
What is 5242880 bytes in MB?
5,242,880 bytes is exactly 5 MiB (binary) and 5.24288 MB (decimal). The value 5,242,880 is 5 × 2^20 — a common file-size limit used by many APIs and web frameworks.
What is 10485760 bytes in MB?
10,485,760 bytes is exactly 10 MiB (binary) and 10.48576 MB (decimal). The value 10,485,760 is 10 × 2^20 — one of the most common upload-size limits in PHP (upload_max_filesize = 10M) and WordPress.
What is 104857600 bytes in MB?
104,857,600 bytes is exactly 100 MiB (binary) and 104.8576 MB (decimal). The value 104,857,600 is 100 × 2^20 — often used as the ceiling for large file uploads or media processing limits.
What is 26214400 bytes in MB?
26,214,400 bytes is exactly 25 MiB (binary) and 26.2144 MB (decimal). The value 26,214,400 is 25 × 2^20 — the classic 25 MiB attachment size that matches Gmail's limit expressed in binary.
Why are most byte values powers of two?
Because the underlying hardware addresses memory in binary. A system with 20 address lines can address 2^20 = 1,048,576 bytes. Programming languages and operating systems have historically defined their limits in terms of these power-of-two values, so a value like 10 MB usually means 10 × 1,048,576 = 10,485,760 bytes in a compiled program, not 10,000,000.
Is 1 MB equal to 1,000,000 bytes or 1,048,576 bytes?
Both are correct depending on context. 1 MB = 1,000,000 bytes under the SI standard. 1 MiB = 1,048,576 bytes under the IEC standard. Windows, macOS, and most programming languages use the binary value (1,048,576) but label it "MB". Storage manufacturers use the decimal value (1,000,000) — which is why a "500 GB" drive shows up as about 465 GiB in Windows.
How many bits in a byte?
8 bits in 1 byte. That means 1 MB contains 8,000,000 bits in decimal or 8,388,608 bits in binary. The bits-vs-bytes distinction is why a 100 Mbps internet connection downloads 12.5 MB per second rather than 100 — divide by 8.
What is the PHP upload_max_filesize in bytes?
PHP's upload_max_filesize uses the shorthand M and G suffixes, which are binary. So upload_max_filesize = 10M means 10 × 1,048,576 = 10,485,760 bytes exactly. The default is 2M (2,097,152 bytes). To change it, use values like 2M, 5M, 10M, 20M, 50M, 100M — each one is a multiple of 1,048,576 bytes.
What is the MySQL BLOB size in bytes?
MySQL has four BLOB sizes: TINYBLOB holds 255 bytes, BLOB holds 65,535 bytes (64 KiB), MEDIUMBLOB holds 16,777,215 bytes (16 MiB), and LONGBLOB holds 4,294,967,295 bytes (4 GiB). These values are the maximums, not the storage size — the actual storage is the size of the data you insert.
What is 1 TB in bytes?
1 TB = 1,000,000,000,000 bytes in decimal (SI). 1 TiB = 1,099,511,627,776 bytes in binary (IEC). 1 TiB is 2^40, one of the classic power-of-two boundaries.
What is 1 GB in bytes?
1 GB = 1,000,000,000 bytes in decimal. 1 GiB = 1,073,741,824 bytes in binary. 1 GiB is 2^30 — the value that appears in browser memory limits, JavaScript's maximum typed-array size, and 32-bit operating-system memory ceilings.
How do I convert bytes to MB in Python?
In Python: bytes_value / 1_000_000 gives decimal MB; bytes_value / 1_048_576 gives binary MiB. Python's standard library does not do automatic unit conversion; you have to choose. For file-size display, most applications use the binary version (÷ 1,048,576) with an "MB" label — matching what Windows Explorer shows.
How do I convert bytes to MB in JavaScript?
In JavaScript: bytes / 1_000_000 for decimal MB; bytes / 1_048_576 for binary MiB. The Node.js ecosystem typically uses the binary version for file sizes. Browsers use binary for the File API's size property and for navigator.deviceMemory.
How do I convert bytes to MB in Excel or Google Sheets?
Use =A1/1000000 for decimal MB, or =A1/1048576 for binary MiB. Excel also has the CONVERT function: =CONVERT(A1,"byte","Mbyte") for decimal or =CONVERT(A1,"byte","Mibyte") for binary.
Is a byte bigger than a bit?
Yes — 1 byte equals 8 bits. A bit is the smallest unit of information (a single 0 or 1), while a byte is the smallest addressable unit in most computer architectures. When you see internet speeds quoted in Mbps (megabits per second) and file sizes in MB (megabytes), the factor of 8 explains why a 100 Mbps connection downloads 12.5 MB per second.
What is 4194304 bytes in MB and why is it special?
4,194,304 bytes equals exactly 4 MiB (binary) or 4.194304 MB (decimal). The value is 2^22. It is special because it is the exact power-of-two value that 32-bit and 64-bit systems use for 4 MiB memory blocks — the maximum size of many historical application allocations, default buffer sizes, and old FAT filesystem limits.
Does this converter upload my data?
No. Every calculation runs in your browser using vanilla JavaScript. Nothing you type is uploaded, logged, or stored on any server. There is no account, no login, and no network request after the page loads.
Does this tool save my values?
Recent values are stored only in your browser's local storage so the tool can offer them back to you. You can clear them with one click on the page. Nothing is ever uploaded to a server.
How does this bytes to MB converter differ from other online converters?
Most byte-to-MB converters silently pick one standard. This one shows both decimal and binary answers side by side, provides one-click access to the power-of-two values programmers actually work with (1024, 1048576, 4194304, 10485760 and more), includes reverse lookup tables for MB-to-bytes, and references common PHP, MySQL, and HTTP byte limits.
Related tools on AIToolsPros
Sources and methodology
- BIPM — The International System of Units (SI) Brochure: authoritative reference for the decimal prefixes kilo, mega, and giga.
- International Electrotechnical Commission: publisher of IEC 60027-2, which introduced the binary prefixes kibi, mebi, gibi, and tebi in 1998.
- NIST — Prefixes for Binary Multiples: US National Institute of Standards and Technology guidance on SI versus IEC prefixes.
- PHP Manual — Using PHP: reference for the
upload_max_filesize,post_max_size, andmemory_limitshorthand suffixes. - MySQL 8.0 Reference Manual — Data Type Storage Requirements: BLOB and TEXT column size limits.
- MDN — File API: reference for the browser file size property used by the drop zone.
- MDN — Content-Length header: HTTP response body size reference.
- Wikipedia — Binary prefix: history and evolution of the decimal-vs-binary prefix systems.
- Wikipedia — Byte: byte definition, bit/byte ratio, and historical context.