← Guides

Developer Guide

Convert Base64 to Text

Decode Base64 to UTF-8 text locally. Covers missing padding, URL-safe -_ alphabets, invalid characters, and output that was never text.

base64 to textdecode base64base64 decoderconvert base64 stringurl-safe base64 decode

Decoding Base64 is the reverse of the encode pipeline: map the alphabet back to bytes, then decode those bytes as UTF-8. SGVsbG8gV29ybGQh is Hello World!. aGVsbG8= is hello. If the bytes were never UTF-8 text — a PNG, a gzip file, an AES blob — the textarea will show mojibake or replacement characters, not a picture.

/tools/base64 in Decode mode does that conversion in the tab. This page is about getting a correct string out, not about producing Base64. Encoding, padding generation, and when to skip text mode altogether are on the text-to-Base64 guide.

Padding has to be restorable

A complete standard Base64 string is a multiple of four characters. YQ== is a. aGk= is hi. aGVsbG8= is hello. If someone trimmed the = signs, the decoder may reject the input.

On /tools/base64, URL-safe Decode puts padding back: it translates -_ to +/ and appends = until the length is a multiple of four. Standard Decode (checkbox off) expects the = to already be there. If a JWT-like value fails, turn URL-safe on before you assume the payload is corrupt.

URL-safe alphabet versus +/

The URL-safe alphabet uses - instead of + and _ instead of /. PDw_Pz4- is the URL-safe form of <<??>>; the standard form is PDw/Pz4+. 8J-Ri_CfjI0 is URL-safe 👋🌍; the padded standard form is 8J+Ri/CfjI0=.

Mixing alphabets is the usual production bug. A query-string token copied into a MIME decoder, or a JSON field that still contains - fed to atob without translation, throws. Check URL-safe when the input contains - or _ and almost no + / =.

Invalid characters

The standard alphabet is A–Z a–z 0–9 + / plus = at the end. Anything else — spaces in the middle of a MIME wrap you forgot to strip, a stray newline, a " from JSON, an ellipsis a mail client inserted — makes /tools/base64 return ⚠ Invalid Base64 input.

Strip whitespace first if you copied a MIME body (those wrap at 76 columns). Strip a data:image/png;base64, prefix if you only wanted the text decoder; that prefix is not Base64. Quotes around a JSON string are not Base64 either.

Garbled output means it was not UTF-8 text

Decode always tries TextDecoder on the bytes. If those bytes were a JPEG, you will see a mess of Latin-1-looking glyphs, �, or an empty-looking control soup. That is success at the Base64 layer and failure at the “this is a sentence” layer.

For an image, take the original string to /tools/base64-to-image. That page requires the full data URI: data:image/TYPE;base64, plus the payload, including the comma. It will not sniff raw iVBORw0KGgo…. If you only have the payload, prepend the prefix yourself (png, jpeg, gif, webp, or svg+xml).

Whitespace, JSON wrappers, and double encoding

A value that still looks like Base64 after one decode was encoded twice. Decode once, paste the result back, decode again, until you see language. Do not loop forever — if the second output is binary garbage, stop and ask whether it was a file.

Pretty-printed JSON will wrap a long Base64 field across lines. Join the lines. Do not decode the whole document; pull the field out, then decode. /tools/base64 is a string tool, not a JSON walker.

Common pitfalls

Decoding with the wrong alphabet looks like “random” failure. Decoding a data URI including the data:image/png;base64, header fails because : , and / in the prefix are not payload. Decoding image bytes as text and then saving the textarea does not reconstruct the file.

Another trap: treating ⚠ Invalid Base64 input as a site outage. The input is not in the alphabet, or padding is wrong. Fix the string; the decoder is local.

  • SGVsbG8gV29ybGQh → Hello World! in Decode mode.
  • URL-safe Decode restores -_ and padding; standard Decode does not.
  • /tools/base64-to-image needs data:image/TYPE;base64, — this tool does not paint pixels.

Worked examples

Padded ASCII

Input
aGVsbG8=
Output
hello

If you only have aGVsbG8, turn on URL-safe Decode so the tool can add the missing =.

Unpadded greeting

Input
SGVsbG8gV29ybGQh
Output
Hello World!

No = because the byte length was a multiple of three. Same result with URL-safe off or on.

URL-safe punctuation

Input
PDw_Pz4-
Output
<<??>>

Enable URL-safe. The standard spelling PDw/Pz4+ decodes with the checkbox off.

Frequently asked questions

Why do I see ⚠ Invalid Base64 input?

A character outside the alphabet, a truncated string, or missing padding in standard mode. Trim whitespace, then try URL-safe Decode if you see - or _.

The output looks like nonsense. Did decode fail?

Base64 probably succeeded and UTF-8 interpretation failed. The bytes were likely an image or other binary. Use /tools/base64-to-image with a data-URI prefix.

Do I need the = characters?

Standard Base64 does. URL-safe mode on this site omits them on encode and restores them on decode. Match the mode to whoever produced the string.

Can I decode a data URI as text?

Only the part after the comma. The data:image/png;base64, prefix is not Base64. For a preview, keep the prefix and use /tools/base64-to-image.

Is the string sent to a server?

No. Decode uses atob and TextDecoder in the browser. Invalid input stays in your tab.

Summary

Decode by restoring padding and the right alphabet, then reading the bytes as UTF-8. SGVsbG8gV29ybGQh is Hello World! on /tools/base64. If the result is binary junk, you needed /tools/base64-to-image and a data:image/TYPE;base64, prefix, not a text decoder. Encoding the other way is a separate guide.

Try it yourself

Put what you've learned into practice with our free browser-native tool.

Open Tool →