Skip to main content
Toolstext-to-base648 min read

Why Base64 makes data about 33% bigger (and when it's more)

The 4-for-3 arithmetic behind Base64's 33% overhead, why one byte becomes four characters, and how line breaks, data URLs and percent-encoding add more.

Published

Cover banner: Why Base64 makes data about 33% bigger (and when it's more), with the free Text to Base64

Base64 makes data about 33% bigger because it stores every 3 bytes as 4 text characters. Each character carries only 6 bits instead of 8, so you need four of them to hold 24 bits. Padding with = rounds the output up to a multiple of 4, which makes very short inputs grow far more than a third.

This explainer works through that arithmetic with real byte counts, shows why small strings can double or even quadruple, and covers the extra costs that push real-world payloads past 33%: line breaks, data: URL prefixes and percent-encoding. Every size below was computed with the encoding libraries behind AltFTool's Base64 URL encoder and Base64 to Text decoder; the Text to Base64 tool produces the same strings.

Why 3 bytes become 4 characters

A byte is 8 bits, so it can take 256 values. Base64 deliberately uses a smaller alphabet of 64 characters (A–Z, a–z, 0–9, + and /) because those characters are plain ASCII that text-only formats such as email bodies, JSON strings and XML carry unchanged. (URLs need the URL-safe variant described below.) Sixty-four values fit in exactly 6 bits.

The encoder therefore regroups the input. RFC 4648, the standard that defines Base64, describes it as taking 24-bit groups of input and writing each as 4 encoded characters. Three bytes are 3 × 8 = 24 bits; four Base64 characters are 4 × 6 = 24 bits. The information is identical, but it now occupies 4 bytes on disk or on the wire instead of 3. Four divided by three is 1.333…, which is where the familiar "33% bigger" comes from.

The classic worked example is the word Man. Its three bytes encode to TWFu: four characters, no padding, exactly 33% larger. Nothing is compressed or lost; Base64 is a reversible change of alphabet, not encryption and not compression.

Padding: why short strings grow far more than 33%

When the input length is not a multiple of 3, the last group is incomplete. Standard Base64 fills the gap with one or two = signs so the output length is always a multiple of 4. For long files that overhead is invisible. For short values it dominates.

Input bytesPadded Base64 charactersUnpadded charactersGrowth (padded)
1 (M)4 (TQ==)2300%
2 (Ma)4 (TWE=)3100%
3 (Man)4 (TWFu)433.33%
5 (hello)8 (aGVsbG8=)760%
13 (Hello, world!)201853.85%
10013613436%
1,0001,3361,33433.6%
1,048,576 (1 MiB)1,398,1041,398,10233.33%
Computed with the base64-url-encoder library's encodedLength function on 13 November 2026.

The rule behind the table is simple: padded length = ceil(bytes ÷ 3) × 4. A single byte still needs a full 4-character group, so it grows by 300%. Once inputs reach a few hundred bytes, the rounding error shrinks and growth approaches 33.33%.

Unpadded Base64, which JWTs and many URL-safe uses prefer, saves the one or two = signs: a 2-byte tail becomes 3 characters and a 1-byte tail becomes 2. RFC 4648 says implementations must include padding unless the specification referring to it says otherwise, which is why some formats keep it and others drop it.

Text with accents or emoji grows from a bigger starting point

Base64 encodes bytes, not letters. Text must first be turned into bytes, usually UTF-8, and many characters take more than one byte. The five-letter word héllo is 6 bytes in UTF-8 because é needs two, so it encodes to 8 characters (aMOpbGxv). A single check mark, ✓, is 3 bytes and becomes 4pyT.

So, compared with the number of visible characters, non-English text can look as if it grew by much more than a third. The 33% applies to bytes; the multi-byte step happens before Base64 sees anything. This is also why the browser's built-in btoa() throws an error on text with characters above U+00FF: MDN's documentation explains that it treats each character as a single byte, so Unicode text must be converted to UTF-8 bytes first.

Text to Base64

Encode text to Base64 (UTF-8 first) and see exactly how many characters you get back.

Open Text to Base64

Line breaks, data URLs and percent-encoding add more

Three common wrappers push real payloads beyond the 33% baseline.

MIME line breaks

Email attachments use the MIME rules in RFC 2045, which require encoded lines of no more than 76 characters. With a CRLF pair between lines, a 1 MiB file becomes 1,398,104 Base64 characters across 18,397 lines, or 1,434,896 bytes in total: about 36.8% larger than the original. That is why you often see "Base64 adds about 37%" quoted for email.

Data URLs

Embedding an image in HTML or CSS as a data: URL adds a short prefix that names the media type and the base64 flag (22 characters for a PNG) on top of the 33%. On a 10 KB icon that prefix is negligible; the bigger cost is that the inlined image cannot be cached separately and bloats every page or stylesheet that carries it. The Image to Base64 converter shows the final string length so you can judge whether inlining is worth it.

Percent-encoding in URLs

Standard Base64 uses +, / and =, which have special meanings in URLs. If you percent-encode them, each one becomes three characters (%2B, %2F, %3D). TQ== turns into TQ%3D%3D: 8 characters for 1 byte. The URL-safe alphabet in RFC 4648 section 5 avoids this by using - and _ instead and usually dropping the padding, so Hello, world! becomes the 18-character SGVsbG8sIHdvcmxkIQ rather than a 24-character percent-encoded string.

Working out the decoded size from a Base64 string

The arithmetic also runs backwards. Strip whitespace, count the characters, divide by 4, multiply by 3, then subtract one byte for each trailing =. TWFu decodes to 3 bytes, TWE= to 2 and TQ== to 1. The Base64 to Text decoder applies the same rule, restores missing padding, and refuses a string whose length leaves a single orphan character, because no valid group can end that way.

A quick sanity check is useful before you paste a large value into a database column or an HTTP header: multiply the original byte count by 4/3 and round up to a multiple of 4. If the column limit, cookie limit or header limit is close, Base64 is the wrong way to carry that data.

When the overhead is worth paying

SituationBase64?Why
Binary inside JSON or XMLUsually yesCan't hold raw bytes
Email attachmentsYes (MIME does it)Text-only channel; about 37%
Small icons inline in CSSSometimesSaves a request, loses caching
Large images or videoNoServe the file directly
Hiding secretsNeverAnyone can decode it
When Base64's overhead is worth paying.

HTTP compression such as gzip can recover part of the expansion on text responses, because Base64 output uses only 64 symbols. For anything large, though, the simplest fix is not to Base64 it at all.

Frequently asked questions

Only for inputs that are a multiple of 3 bytes and have no line breaks. Padding makes short inputs grow much more (1 byte becomes 4 characters, a 300% increase), and MIME line breaks lift a 1 MiB file to about 36.8%.

The = signs are padding. They appear when the input length is not a multiple of 3 bytes: a single equals sign means the last group held 2 bytes, and two of them mean it held 1 byte.

The alphabet swap (- for +, _ for /) does not change the length. Dropping the padding saves up to 2 characters, and avoiding percent-encoding saves 2 extra characters for every +, / or = that would otherwise be escaped.

Base64 counts bytes, and those characters take 2 to 4 bytes each in UTF-8. The growth from letters to bytes happens before Base64 adds its own 33%.

Not without changing the data. You can drop padding where the format allows it, or compress the bytes before encoding, but the 4-for-3 ratio itself is fixed by the 64-character alphabet.

Sources and notes

Links the author listed for this post.

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5

Reader feedback

Was this guide helpful?

Your signal helps the editorial team improve stale or unclear guides faster.

Share this article

Written by

Every byte count and percentage in this article was computed on 13 November 2026 with the encoding libraries behind AltFTool's Base64 URL encoder (encodedLength, encodeToBase64Url) and Base64 to Text decoder (base64ByteLength).

Your inbox, your topics

What do you want more of?

Pick the topics you'd like in your inbox. We've ticked one that matches this guide — change them freely.

Topics you want more of

Up to 200 characters.

Privacy policy

Discussion

0 comments

Loading discussion