What the Base64 decoder does
Decoding reverses Base64: every 4 characters are turned back into 3 bytes. The decoder then checks what the bytes are. If they form valid UTF-8 text, you see the text. If they are binary (an image, a PDF, a ZIP, a gzip file or anything else), the page tells you what it found by its first bytes, shows a hex view and offers a Download file button with the correct extension.
Example
SGVsbG8sIFdvcmxkIQ==
decodes to:
Hello, World!
What the decoder accepts
- Line breaks and spaces. Removed, so MIME and PEM blocks (lines of 76 or 64 characters) work.
- Missing padding.
SGVsbG8is decoded the same asSGVsbG8=. - URL-safe Base64.
-and_are converted to+and/. See Base64URL decode for JWT tokens. - Data URIs. A prefix such as
data:image/png;base64,is removed. To see an image, use Base64 to image. - Several lines. Tick Decode line by line to decode a list of separate Base64 strings.
- Stray characters. Tick Ignore invalid characters to skip anything outside the Base64 alphabet instead of stopping with an error.
Why decoding fails
The decoder names the first bad character and its position. The usual causes:
- The text was cut when it was copied, so the length is not valid (a length that leaves exactly 1 extra character is never correct).
- Quotes, commas,
BasicorBearerwere copied together with the Base64. - A
+turned into a space in a URL or form. Replace spaces with+and try again. - The data is not Base64 at all, for example hex or a hash.
- The result looks like garbage: the data is probably binary, or text in another charset. Try the Base64 to text converter with a different charset.
Decode in code
// JavaScript (browser, UTF-8 text)
new TextDecoder().decode(Uint8Array.from(atob('Y2Fmw6k='), c => c.charCodeAt(0)));
// Node.js
Buffer.from('Y2Fmw6k=', 'base64').toString('utf8');
// PHP
base64_decode('Y2Fmw6k=');
# Python
import base64
base64.b64decode('Y2Fmw6k=').decode('utf-8')
# Shell
echo 'Y2Fmw6k=' | base64 --decode
A note on safety
Decoded data can be anything. Do not open decoded files or run decoded scripts that you do not trust. Decoding on this page only displays or saves the bytes. It never runs them.
See also the Base64 encoder, Base64 to text, Base64 to image and the guide What is Base64?