Decodex

How much file data fits in a 1 MB Base64 field?

Calculate the exact padded length, then subtract any JSON or data URL overhead. A single extra input byte can take a request over the limit.

Identify what the limit actually measures

An original-file limit, a Base64-field limit and an HTTP body limit measure different quantities. Here the limit is 1,000,000 bytes and the payload uses padded standard Base64 without line breaks. Each Base64 character takes one byte when sent as UTF-8.

Round up to groups of three bytes

For n input bytes, the encoded length is 4 ร— ceil(n / 3). The 81-byte Decodex sample PNG becomes 108 characters. A 750,000-byte file fills the example field exactly. One additional input byte starts an entirely new four-character group.

4 ร— ceil(81 / 3) = 108
4 ร— ceil(750,000 / 3) = 1,000,000
4 ร— ceil(750,001 / 3) = 1,000,004

Budget separately for the envelope

If the limit applies to the whole body, count the JSON keys, quotes, braces and any data URL prefix. With limit L and fixed overhead H measured in bytes, at most 3 ร— floor((L โˆ’ H) / 4) input bytes fit. Measure the serialized UTF-8 envelope when filenames or metadata contain non-ASCII characters.

Open the file encoder

Related guides

References

More online tools

Convert images, test your keyboard, and use other handy tools in your browser.

Explore Altomono tools