When a byte count is required

People think in megabytes, but software asks for bytes. Upload forms, API limits, network configuration, database settings and programming constants frequently take an integer number of bytes. Converting a human-friendly figure like 5 MB into the number to type is the job of this page. The default of 10 MB returns 10,000,000 bytes. The converter also runs in reverse, which helps when a log line gives a size in bytes and you want to read it as megabytes. Developers meet this daily when a response header reports a content length of 3,145,728 and a colleague asks for the size in megabytes. The page returns about 3.1457 MB, or exactly 3 MiB if you pick the mebibyte option. Both directions rely on the same factor, one million.

Multiplying by one million

The prefix mega means 1,000,000, so one decimal megabyte is 1,000,000 bytes. A file of 1.25 MB has 1,250,000 bytes, a 3.2 MB photo has 3,200,000 bytes and a 0.75 MB document has 750,000 bytes. Moving the decimal point six places to the right does the same thing. Going the other way divides by a million, so 750,000 bytes is 0.75 MB. The result is exact for any decimal input, because the factor is a power of ten.

Upload limits and attachment sizes

A form that accepts files up to 5 MB means 5,000,000 bytes if the site follows decimal conventions, and 5,242,880 bytes if it follows binary ones. Email services state attachment limits in megabytes, and a 25 MB limit is 25,000,000 bytes in decimal terms. Before you compress a file for upload, convert the limit to bytes and compare it with the byte size that your file manager reports, since the byte count is the unambiguous number. If the file is a few hundred kilobytes under the limit, there is room to spare. If it is close, shave a little more. A scanned contract of 4.8 MB is 4,800,000 bytes, which passes a 5,000,000 byte rule but fails a hypothetical limit set at 4,500,000. Checking in bytes gives a yes or no that does not depend on how a dialog rounds the label.

Configuration values and the M suffix trap

Server software often accepts sizes with suffixes, and the meaning of M varies. In nginx, a value like 10m for the maximum request body means 10 mebibytes, which is 10,485,760 bytes. PHP uses the same convention for upload_max_filesize. A setting of 10,000,000, written as plain bytes, sets the decimal 10 MB. If your requirement says 10 MB in the decimal sense, writing 10m gives you slightly more than you asked for, about 4.9 percent. Decide which meaning you need and type the byte count when precision matters.

Programming with sizes

In code, sizes are integers of bytes. A constant for a 2 MB cache might be written 2,000,000, and a constant for a 2 MiB cache would be 2,097,152. Readers of the code need to know which one was meant, so a comment or a named constant is worth the effort. Use this page to produce the decimal figure when a requirement says megabytes and a vendor spec uses the SI definition, and use the mebibyte converter when a platform documents binary sizes. Network code is a good example: a receive buffer of 4 MB in a design document might be coded as 4,000,000, while the operating system rounds allocations up to its own block size. Reading the byte value back from the system and converting it with this page shows whether the request was honored.

Photos, documents and media

The byte count is what your file manager shows in a details dialog, even when the main view shows megabytes. A photo that reads 3.2 MB in a gallery has about 3,200,000 bytes, and one that reads 3.2 MiB has about 3,355,443. Comparing two files with different labels is only reliable in bytes. When you archive documents, you can sum bytes across a folder and convert once at the end instead of adding rounded megabyte values, which avoids accumulating rounding error.

Estimating storage from counts

To estimate how much space a set of files needs, multiply the average size in bytes by the number of files. A thousand scans of 0.75 MB each total 750,000,000 bytes, or 750 MB. In bytes, the arithmetic is exact, and only the final display needs a conversion to megabytes or gigabytes. This is also the safest way to check a quota: the quota is usually stored as a byte count, so comparing like with like prevents surprises when the total sits close to the limit.

Reading the answer

Eight-digit byte counts are easy to misread. Group digits in threes when you write them down, as in 10,000,000, and keep the original megabyte figure beside the byte count in your notes. If the value will be used in a configuration file, remove thousands separators before pasting. A comma inside a numeric field makes many parsers fail. A good habit is to store the byte count as the source of truth and generate the megabyte label from it, since going from bytes to megabytes loses nothing, while going the other way after rounding can lose digits. If a form asks for megabytes with two decimals, 1,234,567 bytes becomes 1.23 MB and cannot be recovered exactly from that label.

Block sizes and archive overhead

The page converts a size label into a byte count. It does not know about file system block sizes, so a file of 1,250,000 bytes may occupy more disk space than that on a drive that allocates in blocks. It also does not apply compression or account for overhead added by archives or encoding. A folder zipped for transfer, for instance, can end up smaller or larger than the sum of its parts depending on the content, so measure the archive itself when the upload limit is tight. The figure is the nominal size of the megabyte amount you entered. For an exact comparison with a real file, read the byte count the system reports and use that number instead of a rounded megabyte label. Rounded labels hide up to half a unit in the last digit shown, which for a 3.2 MB label is as much as 50,000 bytes.