Base64 Encoder Decoder Complete Guide How to Convert Between Text Binary Data URIs and Files — and Why Base64 Adds 33% to Your File Size
Base64 turns binary data into text — making images embeddable in HTML, files transmittable in JSON, and data copyable as plain text. Here's how encoding works, when to use it, and why it costs you 33% extra size.
You need to embed a small icon in an HTML email. You could: host the image on a CDN (requires an external HTTP request — and email clients block external images by default), or encode the image as a Base64 data URI and embed it directly in the HTML (no external request, image displays immediately). You choose Base64. You paste the icon into a Base64 encoder. The tool outputs a string starting with iVBORw0KGgo... — thousands of characters that represent your 3KB icon. You embed it in your HTML. The email loads. The icon displays. No external requests. No blocked images.
Base64 is the universal translator between binary data and text. It powers data URIs, email attachments, API payloads, and JSON data transport. Here is how it works, when to use it, and why it makes your data 33% larger.
How Base64 Works: The 4-to-3 Ratio
Base64 encoding takes binary data — a sequence of bytes — and converts it to a sequence of 64 printable ASCII characters: A-Z, a-z, 0-9, +, and /. The conversion: every 3 bytes (24 bits) of binary data become 4 Base64 characters (4 × 6 bits = 24 bits). The output is always 33% larger than the input — because every 3 input bytes produce 4 output characters. A 100KB image becomes approximately 133KB of Base64 text.
The 33% overhead is the cost of making binary data text-safe. Base64 characters are all printable ASCII — they survive transmission through email, JSON, XML, and any text-based protocol. Binary data (bytes 0-255) does not survive these transmissions — control characters, non-ASCII bytes, and null bytes are corrupted or stripped. Base64 solves this by encoding binary data into a subset of ASCII that every system can handle. The overhead is the price of compatibility.
When to Use Base64 (and When Not To)
Use Base64 for: embedding small images in HTML/CSS (data URIs for icons, logos, and email images — eliminates HTTP requests), transmitting binary data in JSON APIs (the JSON format does not support binary — Base64 encodes the binary as a string), email attachments (MIME encoding uses Base64 for file attachments), and storing binary data in text-only databases (if you cannot use a BLOB column, Base64 encode the binary data as text).
Do not use Base64 for: large files (the 33% overhead is significant — a 50MB file becomes 66MB of Base64), files that will be transmitted as binary anyway (HTTP file downloads, FTP transfers — these protocols handle binary natively), and performance-critical applications (encoding and decoding Base64 takes CPU time — for large volumes, the overhead adds up).
Base64 vs Base64url: Standard Base64 uses + and / as the last two characters, and = for padding. These characters have special meanings in URLs (+ means space, / is a path separator). Base64url replaces + with - and / with _, and omits the = padding. Use Base64url for URLs, JWT tokens, and query parameters. The Base64 encoder/decoder supports both formats. Encode for data. Decode for viewing. Choose the right format for the destination.
Tools mentioned in this article
Base64 Encoder/Decoder
Encode text to Base64 and decode Base64 back to readable text. Works with standard Base64 and URL-safe variants. Quick way to embed data in URLs or decode API responses.
Image to Base64
Convert any image to a Base64 data URI string. Drag and drop, get the encoded string with the correct MIME type prefix. Copy directly into CSS or HTML.
Base64 to Image Converter
Convert Base64 encoded strings back to image files. Preview and download PNG, JPEG, GIF, WebP, or SVG images instantly. Auto-detects image format.
