Base64 Size Calculator
Calculate the encoded size and overhead of Base64 data.
What the Base64 Size Calculator does
Base64 represents binary data using 64 printable characters, encoding three bytes as four characters. That ratio is fixed, so the encoded form is always about a third larger — the price of surviving transport channels that only handle text.
Formula
Encoded bytes = 4 × ⌈raw bytes ÷ 3⌉Raw bytes ≈ encoded bytes × 3 ÷ 4Overhead = 33.33% before paddingPadding = (3 − raw mod 3) mod 3 "=" characters
Inputs explained
| Input | Unit | Required | Notes |
|---|---|---|---|
| Calculate | one of 2 options | Yes | — |
| Size | number | Yes | Accepts more than 0. |
| Size unit | one of 9 options | Yes | — |
| Data URI prefix length | number | Optional | Characters such as "data:image/png;base64," — that one is 22. Accepts 0 or more. |
How to use it
- Choose Calculate and Size unit.
- Enter Size.
- Optionally add Data URI prefix length.
- Select Calculate.
Worked example
Encoding a 1 MB file as Base64.
- Direction
- Encode
- Size
- 1 MB
1,000,000 bytes is 333,334 three-byte groups, so 1,333,336 encoded characters — 333,336 extra bytes, a 33.33% overhead with two padding characters.
Reading the result
- "Size ratio" converges toward exactly 4/3 only for large inputs — the "encoded size for common raw sizes" table shows small files running higher due to padding, so the fixed 33.3% rule of thumb is really an asymptote, not a constant.
- "Total data URI length" (once a prefix is entered) is the figure that matters for a real size budget, since the MIME prefix adds on top of the already-inflated Base64 payload.
Assumptions and limitations
- This assumes standard Base64 with "=" padding — URL-safe or unpadded variants change the padding character count and sometimes the exact length, which this does not distinguish.
Common mistakes
- Assuming Base64 overhead is "roughly a third" for very small payloads — a 1-byte input still produces 4 characters, which is 300% overhead, not 33%; the fixed ratio only holds once the file is large enough that padding rounding becomes negligible.
Frequently asked questions
Why is Base64 exactly a third bigger?
It maps every 3 bytes (24 bits) to 4 six-bit characters. 4 ÷ 3 = 1.333, so the overhead is fixed at 33.3% regardless of content.
Should I inline images as data URIs?
Only for very small assets. You save a request but pay 33% more bytes, lose separate caching, and block the parent file from streaming.