Base64 Converter

Encode text to Base64 or decode Base64 to text.

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.

Where you meet Base64

  • Email attachments: MIME (RFC 2045) encodes binary attachments as Base64 broken into lines of 76 characters. This tool decodes such a block but does not insert line breaks when encoding.
  • Data URLs: data:image/png;base64,... embeds a small image directly in HTML or CSS. MDN documents the data: scheme.
  • HTTP Basic authentication: the header carries username:password in Base64 (RFC 7617). Anyone who sees the header can decode it, which is why Basic authentication needs HTTPS.
  • JSON Web Tokens: the header and payload of a JWT are Base64url, the URL-safe variant. Paste one here and it is rejected; swap - for + and _ for / first and the claims become readable JSON.
  • Binary fields in JSON and XML: file contents, keys and signatures are embedded as Base64 strings because those formats have no byte type.

Base64 is not encryption

  • No key, no secret: anyone can decode Base64 with a one-line command. It hides nothing from logs, proxies or anyone reading the traffic.
  • Reversible by design: that is the point of an encoding. Encryption is the opposite: unreadable without the key.
  • Encrypt first, encode second: Base64 often wraps bytes that are already encrypted so that they fit in text. The encoding adds no protection of its own.
  • Hashing is different again: a hash is one-way and cannot be decoded at all. The MD5 hash generator page explains the difference.
  • Use real protection when it matters: HTTPS for data in transit and an established library (for example the Web Crypto API with AES-GCM) for data at rest.

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
StandardRFC 4648 section 4: + and /, padded with =Encodes and decodes
Base64urlRFC 4648 section 5: - and _ instead of + and /, padding usually omitted. Used in JWTs and URLsRejected on decode; replace - with + and _ with / first
MIMERFC 2045: the standard alphabet broken into 76-character linesDecodes (line breaks are ignored); the encoder produces one unbroken line
Base32, Base16Smaller alphabets defined in the same RFC, used for TOTP secrets and hex dumpsNot 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.