Base64 encode and decode converts binary data into plain text and back, so bytes can travel safely through systems that only understand text. That one sentence covers a surprising amount of the modern web. Every time an image is embedded in an email, a token is passed in a URL, or a small file is inlined into a stylesheet, Base64 is usually doing the quiet work in the background. This Base64 converter lets you encode base64 and decode base64 live in your browser — text to base64 one way, base64 to text the other — and the guide below explains exactly what Base64 is, how the encoding works character by character, and the handful of practical rules worth knowing so you never get a corrupted string or a confusing error.
What is Base64?
Base64 is a binary-to-text encoding scheme. Computers store everything — text, images, audio, executables — as bytes, and a byte can hold any of 256 possible values. The trouble is that many of those values are not safe to send through text-based channels. Email bodies, URLs, XML, JSON and HTTP headers were all designed for printable characters, and a raw byte stream dropped into any of them can be mangled, truncated or interpreted as a control character.
Base64 solves this by re-expressing arbitrary bytes using only 64 characters that every system agrees are safe: the uppercase letters A–Z, the lowercase letters a–z, the digits 0–9, and the two symbols + and /. That is 26 + 26 + 10 + 2 = 64 characters, which is where the name comes from. Because every one of those characters passes cleanly through text channels, any data encoded this way arrives exactly as it left.
How Base64 encoding works
The mechanism is elegant once you see it. Base64 works in groups of three bytes. Three bytes are 24 bits of data. Instead of splitting those 24 bits into three 8-bit groups, Base64 re-slices them into four 6-bit groups. Six bits can represent 64 values (2 to the power of 6), and each of those values maps to exactly one character in the 64-character alphabet.
So three input bytes always become four output characters. Walk through the word “Cat” as an example:
- The letters C, a, t have ASCII byte values 67, 97, 116.
- In binary that is 01000011 01100001 01110100 — 24 bits in total.
- Re-grouped into six-bit chunks: 010000 110110 000101 110100.
- Those chunks are the values 16, 54, 5, 52, which map to the characters Q, 2, F, 0.
So “Cat” encodes to Q2F0. Decoding simply runs the process in reverse: take four characters, look up their six-bit values, concatenate the 24 bits, and re-slice them back into three bytes. You can watch this happen in real time by typing into the converter above and switching between Encode and Decode.
Padding: why Base64 ends with =
Three-byte groups are tidy, but real data rarely divides evenly by three. When the final group has only one or two bytes left over, Base64 pads the output so it always stays a multiple of four characters. That is the job of the = sign.
- If the last group has one byte (8 bits), it is padded to produce two Base64 characters followed by ==.
- If the last group has two bytes (16 bits), it produces three Base64 characters followed by a single =.
- If the data divides evenly into three-byte groups, there is no padding at all.
The padding carries no data of its own. It is purely a marker telling the decoder how many bytes were really in the last group, so it knows whether to discard the extra bits. This is why a correctly formed Base64 string’s length is always divisible by four, and it is the first thing to check when a decode base64 operation fails: a string that is one character short of a multiple of four is almost always truncated or missing its padding.
URL-safe Base64
Standard Base64’s two symbol characters, + and /, are perfectly fine in email and JSON but cause trouble elsewhere. In a URL, + is often interpreted as a space and / is a path separator; in a filename, / is illegal on most systems. To fix this, a variant called URL-safe Base64 was standardised in RFC 4648.
URL-safe Base64 makes two changes: it replaces + with - (hyphen) and / with _ (underscore), and it usually strips the = padding, since the = character also needs escaping in URLs. The result slots cleanly into query strings, path segments, cookies and filenames. Toggle the “URL-safe Base64” option above to switch the encoder into this mode. The decoder on this page accepts both variants transparently, so you can paste a standard or URL-safe string without changing any setting.
What Base64 is used for
Base64 is everywhere once you know to look for it. A few of the most common places you will meet it:
- Data URIs: small images, fonts and SVGs embedded directly in HTML or CSS as data:image/png;base64,..., saving a separate network request for tiny assets.
- Email attachments (MIME): email was designed for 7-bit text, so every binary attachment you have ever sent was Base64-encoded in transit by the MIME standard.
- JSON Web Tokens (JWT): the three parts of a JWT — header, payload and signature — are each URL-safe Base64. Paste the middle section into the decoder and you will read the claims in plain JSON.
- API tokens and credentials: HTTP Basic Authentication sends username:password as a Base64 string, and many API keys and config values are Base64 for transport safety.
- Embedding binary in text formats: storing a file inside XML, YAML or a database text column, or passing a small payload through a system that rejects raw bytes.
In each case the goal is the same: get binary data safely across a text-only boundary and recover it unchanged on the other side. If you work with structured data a lot, pair this converter with the JSON formatter — decode a JWT payload here, then paste it there to pretty-print and inspect it.
Base64 is encoding, not encryption
This is the single most important thing to understand about Base64, and it is a mistake made constantly. Base64 is not encryption. It provides no security whatsoever. There is no key, no secret and no protection — the transformation is completely public and reversible by anyone, which is exactly what the Decode mode above demonstrates in a fraction of a second.
Base64 only makes data unreadable to a casual human glance, not to any attacker. If you store a password, an API secret or personal data as Base64 thinking it is hidden, you have hidden nothing. Anyone who intercepts the string can decode it instantly. When you genuinely need to protect data, reach for real cryptography: AES or similar for encryption that needs a key, and bcrypt, scrypt or Argon2 for one-way password hashing. Base64 can wrap the output of encryption for safe transport, but it is never a substitute for encrypting in the first place. Treat a Base64 string as plainly readable text, because that is precisely what it is.
UTF-8 and non-English text
A subtle but common bug trips up developers who encode with the browser’s built-in btoa function. That function only handles characters in the Latin-1 range, so the moment your text contains an emoji, an accented letter, or any non-Latin script, a naive call throws an error or mangles the bytes.
The reason is that Base64 operates on bytes, not characters, and characters outside Latin-1 are made of multiple bytes under UTF-8. The correct approach is to convert the text to its UTF-8 byte sequence first, then Base64-encode those bytes. This tool does that automatically — it encodes via btoa(unescape(encodeURIComponent(str))) and decodes via the matching reverse — so “café”, “日本語” and “🎉” all round-trip perfectly. If you have ever seen garbled characters after a Base64 round trip elsewhere, a missing UTF-8 step was almost certainly the cause.
The same principle applies when you decode. If a string was encoded from UTF-8 bytes, it must be decoded back into bytes and then interpreted as UTF-8 to recover the original characters. Skipping that final step is what produces the familiar strings of question marks and boxes. Because this converter keeps both directions symmetrical, you never have to think about it: paste in, read out, and the characters are exactly what you expect regardless of language or emoji.
The 33% size overhead
Base64 is not free. Because it turns every three bytes into four characters, the encoded output is always about one third larger than the original — a 33% overhead, before padding. A 300 KB image becomes roughly 400 KB of Base64 text.
That trade-off is usually worth it for small assets, where avoiding an extra HTTP request outweighs the extra bytes, or for data that genuinely must travel as text. But it is a real cost for large files. Inlining a big image as a data URI can bloat an HTML document, hurt caching (the asset can no longer be cached separately), and slow down first render. The stat strip under the converter shows the exact input and output sizes so you can see the overhead for your specific text and decide whether inlining or linking is the better call. For anything beyond a few kilobytes, a normal file request is almost always faster.
How to encode and decode with this tool
The converter is built to be fast and forgiving. Here is the full workflow:
- Encode base64: leave the mode on Encode, type or paste your text on the left, and the Base64 appears on the right instantly. Hit Copy to grab it.
- Decode base64: switch to Decode and paste the Base64 string. The original text appears on the right. If the input is not valid Base64, you get a clear error rather than a crash or silent garbage.
- URL-safe output: tick URL-safe Base64 to emit the -_ alphabet with padding removed — ideal for URLs, JWTs and filenames.
- Swap: the swap button moves the current output back into the input and flips the mode, so you can instantly verify a round trip — encode something, swap, and confirm it decodes to exactly what you started with.
- Clear: wipe the input in one click when you are done.
Every operation happens locally in JavaScript, which is what makes the tool both instant and private. You can load the full set of utilities, including this one, on the free SEO tools index.
Privacy: why in-browser conversion matters
This converter runs entirely in your browser. Nothing you type or paste is sent to a server, stored or logged — the encoding and decoding happen on your own device, and the data never leaves it. That matters more than it first appears, because the strings people run through a Base64 tool are often exactly the kind you would not want on someone else’s server.
Developers routinely decode JWTs that contain user claims, encode API credentials, and paste config snippets, connection strings and tokens into these tools. Any converter that processes that text on a remote server is a place your secrets could be retained, logged or exposed. In-browser conversion removes that risk entirely, which is why a privacy-respecting base64 encoder and base64 decoder is the safer default for anything sensitive. You can work offline, close the tab, and leave no trace behind.
Quick reference
A few facts worth keeping in one place:
- Alphabet: A–Z a–z 0–9 + / for standard Base64; - and _ replace + and / in the URL-safe variant.
- Ratio: every 3 bytes become 4 characters, so encoded output is about 33% larger than the input.
- Padding: = or == appears only when the input length is not a multiple of three; a valid string’s length is a multiple of four.
- Security: Base64 is reversible encoding, never encryption — treat the output as fully readable.
- Unicode: always convert to UTF-8 bytes before encoding so emoji and non-Latin text survive; this tool does it for you.
Keep those in mind and Base64 stops being a mysterious wall of characters and becomes a simple, predictable transform. Paste your text into the converter above to encode base64 or decode base64 and watch the result update in real time.