The Base64 Inflation

The 33% Tax on Every JWT, Data URI, and API Payload — Measured on Real Data

Published: 2026-08-05  |  jslet Research  |  11 min read  |  Classification: Unrestricted

Executive Summary

Base64 is everywhere: every JWT token you issue, every data URI in your HTML, every API key your service hands out. And it always costs more than the textbook 33%. To quantify the real tax, we measured base64 inflation across the payloads that actually appear in production:

This briefing walks through the three base64 taxes, the data behind each, and a decision framework that tells you exactly when data URIs pay off and when they silently bloat your pages. Every number is reproducible — the benchmark methodology is in the final section, and the Base64 Encoder and Base64 Inflation Calculator tools at jslet will let you measure your own payloads.

Tax 1: The Small-Payload Penalty — 33% Is the Floor, Not the Rule

The textbook claim is that base64 expands data by 33%: every 3 bytes of binary become 4 ASCII characters (each character carries 6 bits, so 4 × 6 = 24 bits = 3 bytes). But that 33% is the asymptotic ratio for large inputs. Small payloads pay more, because base64 pads the final group to a multiple of 3 bytes with = characters, and that padding is pure overhead that cannot be avoided. Our measurements across real payload sizes:

Input sizeBase64 outputInflationTypical use
10 bytes16 chars+60.0%Tiny secrets, nonces, short signatures
32 bytes44 chars+37.5%JWT signature keys, hash digests
52 bytes72 chars+38.5%Small API responses
1 KB1,336 chars+33.6%Favicons, icons
2.6 KB3,508 chars+33.4%JSON API payloads
100 KB133,336 chars+33.3%Images, documents

Read the top rows again: the payloads where base64 overhead matters most — cryptographic keys, JWT components, API tokens — are exactly the ones that pay the most inflation. A 10-byte secret pays double the textbook rate. This is not a rounding detail; it directly affects token size, storage footprint, and transmission cost for the most sensitive, most repeated data in your system.

The fix is not to avoid base64 (it is required for text-safe channels) but to know the real number for your payload size. The Base64 Inflation Calculator computes the exact overhead for any byte count, including the padding penalty — so you stop planning with the 33% approximation and start planning with the true cost.

Tax 2: The Compression Trap — Gzip After Base64 Is 22% Worse

Here is the mistake that costs real bandwidth: someone base64-encodes a payload, then gzips it to "save space." The math quietly fails. We measured it on a realistic 104 KB JSON payload:

PipelineResulting sizevs raw
Raw JSON104,587 bytesbaseline
gzip only19,118 bytes-81.7%
base64 only139,452 bytes+33.3%
base64 then gzip23,349 bytes-77.7% vs raw, but +22.1% vs gzip alone

The result: compressing after base64 encoding produces a file 22% larger than compressing the raw bytes. The reason is structural — base64's 64-character alphabet is highly redundant from a compressor's perspective, but the 4/3 expansion happens before compression and cannot be recovered. The compressor sees 139 KB of text instead of 104 KB of binary; it does a good job on the text, but it can never undo the 33% it never got to see.

The correct pipeline is the reverse: compress first, then encode. Or better — if you control the HTTP channel (and you almost always do), skip base64 entirely. Send raw binary with the proper Content-Type header, and let gzip/Brotli at the transport layer do its job on the original bytes. HTTP was designed for binary; base64 is a workaround for text-only channels like email and URL query strings.

Tax 3: The Silent JWT and Data URI Overhead

Two of the most common base64 uses in production are also the least questioned. Let's measure both.

JWT: a typical token with header, payload, and signature has raw components totaling 177 bytes. Encoded as URL-safe base64 and joined with dots, the token string is 239 characters — 35% larger than the data it carries, and that is before considering that the payload itself is often already-text JSON (which base64 then re-encodes inefficiently). At scale, the overhead compounds: a service issuing 10 million tokens a day with ~60 bytes of average encoding overhead per token moves ~600 MB/day of pure encoding tax across storage and transmission. The overhead is justified (URL-safe tokens need it), but it should be a conscious decision, not an accident — keep claims minimal, avoid duplicating large fields, and watch token size if it shows up in your network metrics.

Data URIs: inlining an image as data:image/png;base64,... embeds it directly in HTML or CSS. The measured impact:

AssetRaw sizeData URI sizeInflation
Favicon1 KB1.4 KB+35.7%
Logo8 KB10.7 KB+33.6%
Screenshot200 KB266.7 KB+33.3%

The hidden cost of data URIs is not just the 33% — it is that inlined assets cannot be cached, shared across pages, or preloaded. A favicon at 1.4 KB is fine; a 267 KB screenshot inlined into every page is a monthly bandwidth bill written directly into your HTML. The break-even analysis is in the decision framework below.

The Decision Framework: When Is Base64 Worth It?

Asset under 5 KB, used onceData URI wins. You save a round-trip, and 33% of a few hundred bytes is negligible. Inline it.
Asset 5-50 KBBorderline. A separate request with long cache headers usually wins — the cache hit on repeat views beats the saved round-trip.
Asset over 50 KBNever inline. The 33% tax plus the inability to cache makes it a clear loss. Serve as a separate file.
JWT / API tokensBase64 is required for text-safe transport. Minimize claims, use short field names, and measure token size in your API metrics.
Binary API responsesSend raw binary with Content-Type. No base64, full compression efficiency. Base64 only if the client is text-only.
Compression pipelinesCompress first, encode second — never the reverse. Or skip encoding when the channel supports binary.

The 2026 answer in one sentence: base64 is a transport workaround, not a storage or compression strategy — pay its tax only where text-safety is mandatory, and measure it where it matters (JWTs, data URIs, API keys), because the real rate is often 35-60%, not 33%.

How To Audit Your Own Base64 Tax

1. Find your base64 inventory. Grep your codebase for base64, btoa, Buffer.from(...).toString('base64'), and data:image/ URIs. You will be surprised how many there are.

2. Measure token sizes. If you issue JWTs, log token byte length in your API metrics. A token that crept from 300 to 600 chars over the years is a bandwidth tax nobody noticed.

3. Audit data URIs. List every data: URI in your HTML and CSS. Anything over 50 KB is a strong candidate for extraction to a separate cached file. Use the Base64 Image Encoder to see the exact URI size before deciding.

4. Check your compression pipeline. If anything in your build does base64-then-gzip, flip the order. The 22% difference we measured is free bandwidth once you fix the pipeline.

5. Set a policy. Document: base64 only for text-safe channels, data URIs only under 5 KB, compression always before encoding. A one-page policy prevents the tax from silently re-accruing.

🧰 Related tools: Base64 Encode / Decode · Base64 Inflation Calculator · Base64 Image Encoder · JWT Decoder · The Bundle Tax (companion briefing)

Frequently Asked Questions

How much does base64 encoding actually inflate data size?

The textbook number is 33%, but real payloads pay more. Our measurements: a 10-byte secret inflates 60%, a 32-byte JWT signature key inflates 37.5%, a 2.6 KB JSON payload inflates 33.4%, and a 100 KB binary inflates exactly 33.3%. The 33% figure is the asymptotic floor for large inputs; small payloads — exactly what JWT headers, API keys, and signature blobs tend to be — pay noticeably more. Calculate your exact number with the Base64 Inflation Calculator.

Is gzip + base64 a good combination for compressing payloads?

No — and it's the most common mistake. We measured a 104 KB JSON payload: gzip alone compresses it to 19 KB (-82%), but base64-then-gzip produces 23 KB — 22% larger. The 4/3 expansion happens before compression and cannot be recovered. The correct order is compress first, then encode. Or better: send raw binary with a Content-Type header and let the transport layer compress it.

When should I use a data URI instead of a separate image request?

Data URIs save a round-trip but pay 33% and can't be cached or shared. Under 5 KB, inline it (a few hundred bytes of overhead is worth the saved request). 5-50 KB is borderline — a separate cached file usually wins on repeat views. Over 50 KB, never inline: a 200 KB screenshot becomes a 267 KB un-cacheable blob in every page. Use the Base64 Image Encoder to see the exact URI size before deciding.

Why is base64 used in JWTs, and does it waste bandwidth?

JWT uses URL-safe base64 so tokens survive URLs, cookies, and Authorization headers without escaping. The waste is real: raw components totaling 177 bytes become a 239-character token — 35% larger. At 10M tokens/day with ~60 bytes average overhead each, that's ~600 MB/day of pure encoding tax. It's justified (text-safe transport), but minimize claims and watch token size in your metrics.

What is the most efficient alternative to base64 for binary data over HTTP?

Send raw binary with the correct Content-Type. No 33% tax, and gzip/Brotli compresses it naturally. Use URL-safe base64 (Base64url) only when text-safety is mandatory. For JSON APIs, base64 only genuinely binary fields; use standard JSON types for everything else. MessagePack or CBOR over HTTP/2 is the efficiency ceiling if your ecosystem supports it.

Methodology & Disclosure

Measurements performed with Python 3.12 stdlib (base64, zlib): random binary of specified sizes encoded with standard base64, length compared to input. JSON payload benchmark: 2,000-item object array (104,587 bytes), compressed with zlib level 9. JWT measurement: realistic header + payload + 32-byte HMAC-SHA256 signature, URL-safe base64, total token length compared to raw component bytes. Data URI measurement: random binary of 1 KB / 8 KB / 200 KB plus the 22-character data:image/png;base64, prefix. All results reproducible — the benchmark script is available on request.

Disclosure: jslet is an independent research project. We are not sponsored by any encoding library, token vendor, or CDN.

References & Further Reading

  1. RFC 4648 (2006). "The Base16, Base32, and Base64 Data Encodings." The authoritative spec for base64 including padding rules. datatracker.ietf.org
  2. RFC 7515 (2015). "JSON Web Signature (JWS)." Base64url encoding in JWT/JWS. datatracker.ietf.org
  3. MDN Web Docs (2026). "Data URLs." When to use data URIs and their performance implications. developer.mozilla.org
  4. web.dev (2026). "Optimize your images" and "Reduce payloads" — data URI and image delivery guidance. web.dev/learn/images

Cite as: jslet Research, 2026 — “The Base64 Inflation.” jslet.com. All benchmark data is original and reproducible with the linked tools.

📜 Copyright & Attribution

© 2026 jslet Research. This article is an original work independently researched and published on jslet. All rights reserved.

Sharing & Reprinting: You may share excerpts (up to 200 words) with a mandatory, do-follow link back to this article's canonical URL.

Preferred Attribution Format: "The Base64 Inflation (2026)" — jslet Research, August 2026. https://www.jslet.com/base64-inflation-tax-real

📡 Enjoyed this? Your JWT is 35% larger than the data it carries, and nobody on your team measured it. RSS covers one encoding/performance reality check per week. RSS Feed → | More options →