How this Base64 converter works
Type or paste text on the left and press Encode. The page turns the text into UTF-8 bytes with TextEncoder and runs the browser's btoa() over those bytes, so accented letters and emoji encode correctly: Hello, wörld! ✓ becomes SGVsbG8sIHfDtnJsZCEg4pyT. Decode reverses the two steps with atob() and TextDecoder. Both directions run in the page's JavaScript; nothing is sent to our server.
Decoding is forgiving where browsers are forgiving: spaces and line breaks inside the Base64 are ignored, so a block wrapped at 76 characters from an email source pastes straight in, and missing = padding is tolerated. It is strict about the alphabet. A string containing - or _ (the URL-safe alphabet used in JSON Web Tokens) or any character outside A-Z a-z 0-9 + / fails with "Invalid Base64 string". Decoded bytes are shown as UTF-8 text, so the Base64 of an image or PDF decodes to replacement characters, not to a usable file.
What Base64 is, and why the output is a third longer
Base64 is a binary-to-text encoding defined in RFC 4648. It takes each group of three bytes (24 bits), splits them into four 6-bit values and writes each value as one of 64 characters: A-Z for 0 to 25, a-z for 26 to 51, 0-9 for 52 to 61, + for 62 and / for 63. Four characters for every three bytes means the output is always one third longer than the input, plus one or two = signs that pad an incomplete final group. You can watch it happen in the tool: ab gives YWI=, abc gives YWJj and abcd gives YWJjZA==.
The scheme exists to carry arbitrary bytes through systems built for text. Email bodies, JSON documents, HTTP headers and XML attributes all expect printable characters, so an image attached to an email, a certificate inside a JSON API response, or a username and password in an Authorization header all travel as Base64. The cost is the extra third; the benefit is that nothing along the way mangles a byte it does not understand.
Variants this tool does and does not handle
RFC 4648 defines several alphabets, and other standards add their own line rules. This converter implements standard Base64 only:
| Variant |
How it differs |
In this tool |
| Standard | RFC 4648 section 4: + and /, padded with = | Encodes and decodes |
| Base64url | RFC 4648 section 5: - and _ instead of + and /, padding usually omitted. Used in JWTs and URLs | Rejected on decode; replace - with + and _ with / first |
| MIME | RFC 2045: the standard alphabet broken into 76-character lines | Decodes (line breaks are ignored); the encoder produces one unbroken line |
| Base32, Base16 | Smaller alphabets defined in the same RFC, used for TOTP secrets and hex dumps | Not supported |
Frequently asked questions
Why is the Base64 output longer than my text?
Every three bytes become four characters, so the encoded form is four thirds of the original: 3 MB of file becomes 4 MB of Base64. Padding adds at most two more characters. Text with accents or emoji grows a little more than plain ASCII, because UTF-8 spends two to four bytes on each of those characters before encoding begins.
Why does a JWT or URL-safe string fail to decode?
Because it uses the Base64url alphabet, where - and _ stand in for + and /, and the browser's atob() accepts only the standard alphabet. Replace those two characters and decode again; missing padding is fine. Each JWT segment between the dots decodes separately.
Can I decode a Base64 image here?
Not into a file. The decoder treats the result as UTF-8 text, so image bytes come out as unreadable characters. To view an image, prefix the Base64 with data:image/png;base64, (or the matching type) and open that as a URL in a new browser tab, or use a tool that writes decoded bytes to disk.
Does my text leave the browser?
No. Encoding and decoding use btoa() and atob() inside the page, and no request carries your text. Like every page on this site, it loads the Ahrefs Web Analytics script, which records the visit, not what you type.
Related tools: decoded JWT segments and API payloads are usually JSON, which the JSON formatter validates and indents. A Base64 string placed in a query string still needs the URL encoder, because +, / and = are reserved characters in URLs.