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 ÷ 4
  • Overhead = 33.33% before padding
  • Padding = (3 − raw mod 3) mod 3 "=" characters

Inputs explained

InputUnitRequiredNotes
Calculateone of 2 optionsYes
SizenumberYesAccepts more than 0.
Size unitone of 9 optionsYes
Data URI prefix lengthnumberOptionalCharacters such as "data:image/png;base64," — that one is 22. Accepts 0 or more.

How to use it

  1. Choose Calculate and Size unit.
  2. Enter Size.
  3. Optionally add Data URI prefix length.
  4. 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.

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.

Related calculators