What Is Base64 Encoding?
Base64 is a binary-to-text encoding scheme that converts any data — text, images, files — into a string of printable ASCII characters. It uses a 64-character alphabet (A-Z, a-z, 0-9, +, /) to safely represent binary data in text-based formats like JSON, XML, HTML, and email. The encoded output is roughly 33% larger than the original data.
Common Use Cases
Data URIs — embed small images directly in CSS or HTML to reduce HTTP requests. API payloads — encode binary attachments in JSON requests. Email — MIME encoding uses Base64 for attachments. URL parameters — safely pass binary data through URLs.
How to Use This Base64 Tool
- Paste text or pick a file — Type or paste text to encode, paste a Base64 string to decode, or switch to File to encode any file.
- Select the operation — Choose Encode to convert text to Base64, or Decode to convert Base64 back to readable text.
- Choose the variant — Standard Base64, or URL-Safe (replaces + and / with - and _ and drops the = padding). For files, Data URI adds the data: prefix.
- Copy the result — Click Copy to grab the encoded or decoded output.
Worked example: what this tool actually outputs
On October 12, 2026 we ran the tool's own encode and decode functions (copied from this page) in Node 22, then confirmed the edge cases on this page in Chromium. Text is encoded as UTF-8 first, which is what makes non-ASCII input work: plain btoa() throws on any character above U+00FF.
| Input | Bytes (UTF-8) | Standard output | URL-safe output |
|---|---|---|---|
| RFC 4648 test vectors f, fo, foo, foobar | 1, 2, 3, 6 | Zg== Zm8= Zm9v Zm9vYmFy | padding removed: Zg Zm8 Zm9v Zm9vYmFy |
| café | 5 | Y2Fmw6k= | Y2Fmw6k |
| 👍 | 4 | 8J+RjQ== | 8J-RjQ |
| ??? | 3 | Pz8/ | Pz8_ |
All seven RFC 4648 section 10 test vectors match exactly. Decoding goes through the browser's atob(), which follows the WHATWG forgiving-base64 rules:
| Pasted into Decode | Result |
|---|---|
SGVsbG8 (no padding) | Hello: missing = is accepted |
SGVs + line break + bG8= | Hello: spaces and line breaks (MIME-wrapped text) are ignored |
data:text/plain;base64,SGk= | Hi: a data: prefix is stripped |
SGVsbG8== | Error: one = too many |
Pz8_ with URL-Safe off | ??? in either setting: Decode now accepts both alphabets |
Y2Fm6Q== (Latin-1 bytes for café) | The 4 bytes 63 61 66 e9, shown as hex (not valid UTF-8) with a download button |
iVBORw0KGgo= (the first 8 bytes of a PNG) | 89 50 4e 47 0d 0a 1a 0a, recognised as a PNG and downloadable as decoded.png |
- Size: every 3 bytes become 4 characters. Output length is 4 × ceil(n / 3): 1 byte becomes 4 characters (400%), 10 bytes become 16 (160%), 1,000 become 1,336 (133.6%), and large inputs settle at 133.3%. The "about 33% larger" rule only holds once the input is more than a few hundred bytes.
- Decode handles binary data. Decoded bytes are shown as text when they are valid UTF-8. Anything else (an image, a PDF, Latin-1 text) is shown as a hex dump of the first 512 bytes, with the file type guessed from its signature and a button that downloads the exact bytes. Until October 12, 2026 this case reported “Invalid Base64 string” although the input was valid.
- No MIME line wrapping. Encoded output is one unbroken line. Email bodies under RFC 2045 need lines of at most 76 characters; the tool does not insert them (decoding wrapped text works).
- URL-Safe follows RFC 4648 section 5 and drops the padding, as JWTs do (RFC 7515). Toggling it re-encodes what is in the box, text or file, straight away. Decode accepts either alphabet, padded or not, so the toggle only affects encoding. A data: URI is always written in standard Base64, because RFC 2397 data URIs use it.
- File mode: any file is read as raw bytes and encoded in full; Data URI adds the
data:<type>;base64,prefix using the type the browser reports. Input size and Ratio use the file’s real size: a 3,000-byte file shows Input 2.9 KB, Output 3.9 KB, Ratio 133% (it showed “Input: 16 B, Ratio: 25000%” before October 12, 2026). Checked in Chromium against Python’s base64 module for standard and URL-safe output. - Base64 is not encryption. Anyone can decode it, as the table above shows.
Sources
Checked on .
- RFC 4648: The Base16, Base32, and Base64 Data Encodings (sections 4, 5 and 3.2 on padding)
- RFC 2045: MIME Part One, section 6.8 (Base64 lines of at most 76 characters)
- WHATWG Infra Standard: forgiving-base64 decode (what atob() accepts)
- MDN: Base64 glossary (btoa/atob and the Unicode problem)
- RFC 7515: JSON Web Signature, section 2 (base64url without padding)
Frequently Asked Questions
Built by Derek Giordano · Part of Ultimate Design Tools