Skip to main content
Unit ConvertersFree · no sign-up

MB to Bytes Converter

Convert megabytes to bytes — one million per MB, unless the thing reporting it means 1,048,576.

Updated

bytes

5,000,000B

5 MB = 5,000,000 B

Advertisement

In short

How many bytes are in 1 MB?

1,000,000 bytes. Multiply megabytes by a million, so 5 MB is 5,000,000 bytes. If the system you are configuring counts in binary, one MB is 1,048,576 bytes instead, and 5 MB becomes 5,242,880 — about 4.86 percent more room than the decimal figure.

Which of the two you want depends on the software reading the number, not on the number.

megabytes to bytes — quick reference

megabytes (MB)bytes (B)
0.5 MB500,000 B
1 MB1,000,000 B
2 MB2,000,000 B
5 MB5,000,000 B
10 MB10,000,000 B
25 MB25,000,000 B
100 MB100,000,000 B
500 MB500,000,000 B
Computed from the exact factor — rounded only for display.

The formula, worked line by line

One multiplication by a million, or one by 1,048,576 for the binary answer. Both are below. The arithmetic is not the hard part of this conversion and never has been; choosing which of the two results to commit to a configuration file is.

A limit written in megabytes is an opinion. A limit written in bytes is an instruction.
Why this direction ends in an integer

That is the whole argument for doing the conversion here rather than leaving it to whatever reads the setting. The value you write down is the value that will be enforced, and it should not depend on which library happens to parse it.

bytes = megabytes x 1,000,000
bytes = mebibytes x 1,048,576
1 MB = 1,000,000 bytes
1 MiB = 2^20 = 1,048,576 bytes
5 MB = 5,000,000 bytes;  5 MiB = 5,242,880 bytes
megabytes against bytesA twin scale: megabytes along the top against bytes along the bottom, with 5 MB marked.MBB00125125,000,000250250,000,000375375,000,000500500,000,000MBB
Megabytes along the top against the byte count below, with the binary reading beside it.
Sizing a quota for ten thousand attachments
Average attachment
2.4 MB
Attachments
10,000
Decimal total
24,000,000,000 bytes
Binary reading of the same
25,165,824,000 bytes
Difference
1,165,824,000 bytes
Gap at this scale
over a gigabyte

At one file the two scales differ by a rounding error. At ten thousand the same 4.86 percent has become more than a gigabyte of storage that either exists in the plan or does not. This is why the divisor is worth pinning down before the figure is used to buy anything.

Where each scale actually shows up

Storage vendors and network equipment use the decimal prefixes, which is why a drive sold as 1 TB holds a trillion bytes. Operating systems have historically used the binary quantities with decimal names, which is why that drive appears as 931 GB. Neither is lying; they are counting in different units and only one of them says so.

The two ladders side by side

Multipliers from the byte up
kilobyte, KB
x 1,000
kibibyte, KiB
x 1,024
megabyte, MB
x 1,000,000
mebibyte, MiB
x 1,048,576
gigabyte, GB
x 1,000,000,000
gibibyte, GiB
x 1,073,741,824

The gap compounds by roughly 2.4 percent per rung: 2.4 percent at kilo, 4.86 at mega, 7.37 at giga, 10 at tera. That is why the same misunderstanding is a curiosity on a small file and a budget item on a storage array.

If you take one habit from this page, make it the smallest one: when a number will be read by software, write the integer. Every unit label attached to a figure is another place where two people can agree on the words and disagree on the value.

How to use the MB to bytes converter

A megabyte is a million bytes, so this is a multiplication by 1,000,000 and six places to the right. The reason to do it deliberately rather than in your head is that this direction usually ends with the number being written down somewhere permanent, where it will be obeyed literally by software for years.

That is the difference between the two directions of this conversion. Reading a count off a log is a question about something that already happened. Turning a stated limit into a byte figure is a decision, and the wrong divisor produces a limit that is out by nearly five percent in a place nobody will look again.

1,000,000

Bytes in one megabyte

decimal, SI

1,048,576

Bytes in one mebibyte

2^20, written MiB

4.86%

How much larger the binary unit is

per megabyte

Advertisement

The practical question is which figure the thing you are configuring expects. Most of the time you do not have to guess, because a well-written setting either takes a plain byte count or takes a suffix whose meaning is documented. When a field accepts a bare number, it almost always means bytes, and that is the number this page gives you.

There is a second reason to write bytes rather than megabytes, and it has nothing to do with which divisor is correct. A limit expressed as a round megabyte figure invites somebody to change it by editing the megabyte figure, and round numbers drift upward. A limit expressed as 5,242,880 tends to be left alone, which is usually the right outcome for a limit.

Common limits in both scales
1 MB
1,000,000 B · 1,048,576 B binary
2 MB
2,000,000 B · 2,097,152 B binary
5 MB
5,000,000 B · 5,242,880 B binary
10 MB
10,000,000 B · 10,485,760 B binary
25 MB
25,000,000 B · 26,214,400 B binary
100 MB
100,000,000 B · 104,857,600 B binary

The right-hand column is what you get if the tool you are configuring was written by someone thinking in powers of two. Five megabytes of headroom differs by 242,880 bytes between the two columns, which is roughly a quarter of a megabyte given away or withheld.

Same question, three orders of magnitude up

Gigabytes to bytes runs the identical multiplication with a billion instead of a million, and the gap between the decimal and binary answers widens from 4.86 percent to 7.37.

Open GB to bytes

Megabyte figures converted to exact byte counts on both scales, so a limit can be written as an integer rather than a unit that two systems may read differently.

MegabytesBytes (decimal MB)Bytes (binary MiB)
0.5 MB500,000524,288
1 MB1,000,0001,048,576
2 MB2,000,0002,097,152
5 MB5,000,0005,242,880
10 MB10,000,00010,485,760
25 MB25,000,00026,214,400
50 MB50,000,00052,428,800
100 MB100,000,000104,857,600
250 MB250,000,000262,144,000
500 MB500,000,000524,288,000
1,000 MB1,000,000,0001,048,576,000
Middle column multiplies by 1,000,000 per SI. Right column multiplies by 1,048,576, which is 2^20 and gives mebibytes under IEC 80000-13.

Advertisement

Why a limit belongs in bytes, not megabytes

A size limit is a contract between two pieces of software that were probably written by different people. Everything about it should be unambiguous, and a figure in megabytes is not: the person setting it and the person hitting it can each be right about what it means and still disagree by five percent.

A 5 MB upload limit, disagreed about
Limit as written
5 MB
Server enforces
5,242,880 bytes
Client validates against
5,000,000 bytes
A file of 5,100,000 bytes
blocked by the client
The same file at the server
would have been accepted
Outcome
a rejection nobody can reproduce

The user is told the file is too large by a client that is stricter than the server it is protecting. Nothing in the logs shows a failure, because the request was never sent. Both numbers came from the same "5 MB", and the disagreement is invisible until someone converts both to bytes.

The fix is not to decide which scale is correct — both are real units and both are defended. The fix is to stop passing the ambiguous form around. Convert once, at the point the limit is decided, and let every system downstream receive the same integer.

Picking the divisor on purpose

When a limit has to interoperate with something you do not control, the safer choice is the smaller figure, the decimal one. A cap of 5,000,000 bytes will be honoured by a binary-thinking system as comfortably under its own 5 MiB, whereas a cap of 5,242,880 set against a decimal-thinking consumer is over its stated maximum.

Do

  • Write the full byte count into configuration rather than a suffix
  • Pick the decimal figure when the other side is out of your control
  • Say MiB in prose when you mean 1,048,576 bytes
  • Convert once, at the point the limit is agreed

Don't

  • Assume a K, M or G suffix means the same thing in two programs
  • Set a client-side check tighter than the server it protects
  • Change a limit by editing the megabyte figure and reconverting
  • Mix a decimal cap with a binary progress bar in the same interface

One more habit worth keeping: when you raise a limit, raise it in bytes too. Doubling 5,242,880 gives 10,485,760, which is still a clean binary figure. Doubling "5 MB" to "10 MB" and reconverting invites a second decision about the divisor, and the second decision is often not the same as the first.

Every megabytes value, worked out

115 common megabytes figures each get their own page, with the answer, the arithmetic, what rounding costs, and the nearest real-world reference point on the scale.

Advertisement

Questions people ask

How many bytes are in 1 MB?

One million bytes under the SI definition, so 5 MB is 5,000,000 bytes. The binary unit with the same rough size is the mebibyte, MiB, which holds 1,048,576 bytes, making 5 MiB equal to 5,242,880 bytes. Both units are in current use and they differ by about 4.86 percent.

Should I set an upload limit in MB or in bytes?

In bytes. A limit in megabytes has to be interpreted by whatever reads it, and different programs resolve the same suffix to different values. Writing the exact count means the client, the server and the proxy in between all enforce the identical figure, which removes a whole class of rejections that cannot be reproduced.

Does 5M in a config file mean 5,000,000 bytes?

Not reliably. The suffix is defined by the program parsing it, not by any standard, and implementations differ: some expand M to 1,000,000 and others to 1,048,576. If the field accepts a plain number it almost certainly means bytes, and writing the full count avoids depending on a convention you did not choose.

Which figure should I pick when I do not control the other side?

The decimal one, because it is smaller. A cap of 5,000,000 bytes sits comfortably inside a binary-thinking system that considers 5,242,880 to be five megabytes, so nothing is rejected unexpectedly. Choosing the larger binary figure against a decimal consumer means your stated limit exceeds the one actually enforced.

Why do a file manager and a website report different sizes for one file?

Because one is dividing by 1,048,576 and calling the result MB while the other divides by 1,000,000. The underlying byte count is identical and neither program is wrong about it. The discrepancy is roughly 4.86 percent at megabyte scale and grows to about 7.37 percent once the figures reach gigabytes.

Sources

Where the constants and formulas on this page come from. Each line names the figure it backs.

  1. The binary multiples kibi, mebi and gibi denote 2^10, 2^20 and 2^30, distinct from the decimal SI prefixes kilo, mega and giga.

    IEC 80000-13 Quantities and units — Part 13: Information science and technologyInternational Electrotechnical Commission

  2. The SI prefixes mega and giga denote 10^6 and 10^9 exactly, and are not to be used for powers of two.

    The International System of Units (SI), 9th editionBIPM, 2019