Cookies for analytics and advertising
We use cookies for analytics and advertising, both sent to Google. Refusing changes nothing you can see.Read the privacy page
1 B = 0.000001 MB
A megabyte is 1,000,000 bytes in the decimal system that standards and networks use, so a byte count becomes megabytes by moving the decimal point six places. The raw byte figure is the exact one — an integer with no rounding anywhere in it — and the megabyte number you turn it into is a display, which is a distinction worth keeping when the two are compared.
5000000 B is 5 MB
— a photograph from a phone.
1024 B is 0.001024 MB
— a kibibyte, which is where the confusion starts.
5000000 B is 5 MB
— a song at a good bitrate.
4000000000 B is 4000 MB
— a film at ordinary quality.
| B | MB |
|---|---|
| 1000 | 0.001 |
| 2000 | 0.002 |
| 5000 | 0.005 |
| 10000 | 0.01 |
| 50000 | 0.05 |
| 100000 | 0.1 |
| 500000 | 0.5 |
| 1000000 | 1 |
Convert B to MB
A byte is eight bits, though that was not always fixed — early machines used six, seven or nine. The eight-bit byte won because it holds one character of text and divides neatly in half.
A megabyte is a million bytes. Storage manufacturers have always used this decimal meaning, which is why their capacities look larger than what a computer reports.
Going from bytes to megabytes moves the decimal point 6 places to the left and changes nothing else. There is no factor to remember and no rounding to decide: the digits stay in the same order and only their position changes.
1,234 B is 0.001234 MB — same digits, moved along. That is worth knowing because it is the one kind of conversion you can check at a glance: if the digits of the answer are not the digits you started with, something other than the conversion has happened to them.
Bytes are what every layer underneath the display actually counts. A directory listing without formatting flags, the st_size field of a stat call, a Content-Length header, the size attribute in an object-storage listing and the length field in a log line are all integers of bytes, because a byte is the one unit in this area with no dialect: it is the same quantity in every system, on every platform, under every convention.
That is precisely why interfaces emit it. The moment a size is turned into megabytes it has acquired both a divisor and a rounding, and neither travels with the number. An API returning 5242880 has told you something unambiguous; an API returning "5.24 MB" has told you something that needs a footnote. Converting is your job, at the end, and knowing that keeps the exact figure available for as long as it is useful.
This page divides by 1,000,000, because mega is an SI prefix meaning 10⁶ and that is the meaning used by networking standards, by storage manufacturers and by the specifications that define the headers you are reading. 5,000,000 bytes is 5 MB, 250,000 bytes is 0.25 MB, and 12,345,678 bytes is 12.35 MB. There is no factor to remember; the digits do not change, only their position does.
The binary reading divides by 1,048,576 instead and produces a mebibyte figure. 5,000,000 bytes is 4.77 MiB; 5,242,880 bytes is 5.00 MiB and 5.24 MB. The two answers for one file differ by 4.9 per cent, which is small enough to be missed and large enough to matter when a number is being checked against a quoted limit. If a byte count divides suspiciously cleanly by 1,048,576, it was almost certainly chosen in binary units.
The common Unix tools mean 1,024 unless told otherwise. GNU ls with -h prints 5.0M for 5,242,880 bytes; du and df report in 1,024-byte blocks; and the K, M and G suffixes across that family are binary by default. All of them accept a switch to powers of ten — --si on ls and du, and an equivalent on df — which changes both the arithmetic and the suffixes it prints, to kB, MB and GB.
Browser developer tools, cloud consoles and object-storage dashboards are less consistent, and the only reliable method is to check one file whose byte count you already know. Take something exactly 1,048,576 bytes long: a tool that calls it 1.0 MB is binary, and a tool that calls it 1.05 MB is decimal. That single test settles the question for every other number the tool will ever show you.
A byte count taken from an HTTP response is measuring something narrower than a file on disk. Content-Length is the length of the body being transferred, so if the server applied gzip or brotli it is the compressed length — for HTML, CSS, JavaScript and JSON that is commonly a fifth to a third of the stored size. A page that reports 45,000 bytes over the wire may be 180,000 bytes of source.
Two further gaps are worth knowing. Response headers are not counted in it, so a small response can cost more than its Content-Length suggests; and a chunked response has no Content-Length at all, which is why some tools show a size only once the transfer has finished. When comparing a downloaded file against a served one, compare the file on disk after decompression, or compare compressed against compressed, but do not mix the two.
A stat call returns two size-shaped fields and they answer different questions: the length of the file in bytes, and the number of blocks allocated to it. On a filesystem with 4,096-byte blocks, a 1,000-byte file has a length of 1,000 and occupies 4,096, and a 4,097-byte file occupies 8,192. Converting the first to megabytes tells you how much data there is; converting the second tells you how much of the volume is gone.
The two diverge in both directions. A directory of ten thousand small files can occupy several times the total of their lengths, which is the usual explanation for a disk that is fuller than its contents. A sparse file goes the other way and occupies far less than its length, because the runs of zeros were never written. Any byte count worth converting should come with a note about which of the two it is.
Converted sizes are for judgement, not for arithmetic. 4 MB is a photograph from a phone, 5 MB is a music track at a good bitrate, 25 MB is around the limit a mail service will accept in a message, and 100 MB is the point at which most upload forms start refusing. Turning 4,187,593 bytes into "about 4 MB" puts it on that scale immediately, which is the entire purpose of doing it.
What the megabyte figure should not do is go back into a calculation. Round-tripping a size through two decimal places of MB loses up to 5,000 bytes, and a total assembled from a hundred such figures carries a comfortably visible error. Sum the integers, divide once, and display the result — the same rule that applies to money, and for the same reason.
There are cases where converting at all is the mistake. Verifying that a download completed means comparing byte counts, because a truncated file will very often round to the same megabyte figure as a whole one. Comparing two builds of an asset means comparing bytes, because a 3 kB regression is invisible in a number quoted as 1.2 MB. Detecting a duplicate, matching a checksum against a length, diffing a manifest — all of those want the integer.
The same applies to anything with a hard boundary. A field limit, a request size cap and a memory allocation are all specified in bytes and enforced in bytes, and a value that is close to the limit after rounding may be over it in fact. Convert to megabytes to think about a number, and go back to bytes to act on it.
1,000,000 in the decimal system used by standards bodies, networks and storage manufacturers, which is what this page converts. The binary unit that holds 1,048,576 bytes is the mebibyte, MiB, and it is 4.9 per cent larger. Both units are in daily use and the letters printed next to a number are not a reliable guide to which one produced it.
5.24 MB in decimal megabytes, and exactly 5.00 MiB in mebibytes. A round number in one system is an awkward one in the other, and a byte count that comes out suspiciously round when divided by 1,048,576 is a strong hint that whoever chose it was thinking in binary units.
No. GNU ls with -h uses powers of 1,024 and prints suffixes such as K, M and G, so a file it calls 5.0M is 5,242,880 bytes rather than 5,000,000. The --si flag switches the same tool to powers of 1,000 with the suffixes kB, MB and GB. The two outputs for one file differ by 4.9 per cent at megabyte scale.
Because it counts what is being sent, not what is stored. If the response is compressed with gzip or brotli, Content-Length is the compressed length, and for text that is routinely a fifth of the file. It is also the length of the body only, so headers, and any chunked-transfer framing, sit outside it.
No. Keep the integer and convert only for display. A byte count is exact and comparable — two files with the same byte count are the same length, and a difference of one byte is visible — while a figure rounded to two decimal places in MB has thrown away up to 5,000 bytes of information that cannot be recovered.
Three separate reasons, and they are worth telling apart. The tool may be dividing by 1,048,576 rather than 1,000,000, which is a 4.9 per cent difference. It may be reporting space occupied on disk rather than file length, which rounds up to a whole block of usually 4,096 bytes. Or it may be reporting a compressed transfer size rather than the stored file.
One MB is 1000000 B. It is the same relationship read backwards, so an answer from one page put through the other has to come back to where it started.
The claims this page makes about data units are checkable, and these are the documents that settle them.
The factor is a constant in the page and the arithmetic is four operations, so nothing is sent anywhere and nothing needs to be. The number you type never leaves the browser — there is no request for it to travel in.