Base64 Decoder
Paste a Base64 string and read what is inside it. Decoding is UTF-8 aware, so accented letters and emoji come back as themselves instead of mojibake (the garbled text you get when bytes are read with the wrong encoding). The string is decoded in this page, so nothing is uploaded.
1 Base64 Decoder example
Input Base64
SGVsbG8gV29ybGQhClRoaXMgaXMgYSB0ZXN0IGZvciBCYXNlNjQgRGVjb2Rlci4= Decoded Text
2
Hello World!
This is a test for Base64 Decoder. 2 When to use the Base64 Decoder
Reading an API response
Decode the payload before you debug the code. Payloads, certificates and file contents often arrive Base64-encoded. Reading the decoded value tells you whether the problem is the data or the encoding.
Checking a header
An Authorization: Basic header is base64(user:password). Decode it to see which account a request used. For example, dXNlcjpwYXNz decodes to user:pass.
Usage
Decoding a Base64 string back to UTF-8
- 01 Paste the Base64 string into the left editor. The decoded text appears on the right immediately.
- 02 Click Upload File to load a .txt file that contains Base64, or Load URL to fetch one from an endpoint that allows cross-origin requests.
- 03 If the input is not valid Base64, an error message appears above the editor. Look for characters outside the alphabet, such as quotes or a trailing comma. URL-safe - and _, missing padding and a data: prefix are handled for you.
- 04 Copy Result puts the decoded text on the clipboard; Clear wipes both panels.
In code
Decoding Base64 back to text in JavaScript, PHP and Python
JavaScript / Node.js
jsconst encoded = "SGVsbG8sIHfDtnJsZCEg8J+MjQ==";
// Node.js: decode to bytes, then to a UTF-8 string
const text = Buffer.from(encoded, "base64").toString("utf8");
console.log(text); // Hello, wörld! 🌍
// Browser: atob() returns a "binary string", so convert bytes to UTF-8
const binary = atob(encoded);
const bytes = Uint8Array.from(binary, (c) => c.charCodeAt(0));
console.log(new TextDecoder().decode(bytes));
// URL-safe input without padding
console.log(Buffer.from("SGVsbG8sIHfDtnJsZCEg8J-MjQ", "base64url").toString()); Node's Buffer is lenient: it ignores whitespace and missing padding. atob() is strict about padding and throws on invalid input.
PHP
php<?php
$encoded = "SGVsbG8sIHfDtnJsZCEg8J+MjQ==";
// Strict mode returns false on characters outside the Base64 alphabet
$text = base64_decode($encoded, true);
if ($text === false) {
die('Invalid Base64 input');
}
echo $text, PHP_EOL; // Hello, wörld! 🌍
// Accept URL-safe input: restore + and /, then re-add padding
$urlSafe = "SGVsbG8sIHfDtnJsZCEg8J-MjQ";
$std = strtr($urlSafe, '-_', '+/');
$std .= str_repeat('=', (4 - strlen($std) % 4) % 4);
echo base64_decode($std, true), PHP_EOL; Without the second argument, base64_decode silently skips invalid characters, which can hide corrupted input.
Python
pythonimport base64
import binascii
encoded = "SGVsbG8sIHfDtnJsZCEg8J+MjQ=="
try:
text = base64.b64decode(encoded, validate=True).decode("utf-8")
except (binascii.Error, UnicodeDecodeError) as e:
raise SystemExit(f"Cannot decode: {e}")
print(text) # Hello, wörld! 🌍
# URL-safe input without padding: add "=" until the length is a multiple of 4
url_safe = "SGVsbG8sIHfDtnJsZCEg8J-MjQ"
padded = url_safe + "=" * (-len(url_safe) % 4)
print(base64.urlsafe_b64decode(padded).decode("utf-8")) Troubleshooting
Missing padding, URL-safe dashes and mojibake
- binascii.Error: Incorrect padding
- The string length is not a multiple of 4. Padding was stripped, often because it came from a JWT or a URL. Append = characters until the length divides by 4.
- InvalidCharacterError: The string to be decoded is not correctly encoded
- atob() found a character outside A-Z, a-z, 0-9, + and /. Common causes are - and _ from base64url, spaces or newlines, or a data: URI prefix that was not removed.
- Decoded output looks like ö or question marks
- The bytes are UTF-8 but were read as Latin-1. Decode to bytes first, then to a UTF-8 string. For non-ASCII text, the raw atob() result is always wrong.
- Output is unreadable binary
- The Base64 wraps bytes that were never text, such as an image, a PDF or a gzip stream. Write the bytes to a file with the right extension, or use the Base64 to Image tool.
Details
Why Base64 is transport encoding, not encryption
Decoding gives you bytes. The same Base64 string could be UTF-8 text, a PNG or an encrypted blob, and nothing in the encoding says which. However, the first few characters usually tell you: iVBORw0 is a PNG, /9j/ is a JPEG, eyJ is a JSON object and H4sI is gzip.
Base64 is not encryption, even though the output looks like noise. There is no key, and anyone can reverse it in one line. Treat a Base64 password in a config file or a JWT payload as a plain-text password.
RFCs
RFC 4648 Base64 decoding standard
Guides
Guides and tutorials
- Fix JSON.parse Unexpected Token Errors: Every Cause Every JSON.parse SyntaxError and its fix: unexpected token <, single quotes, trailing commas, comments, end of input, BOM and NaN. Read guide →
- Base64 vs URL Encoding: When to Use Which Base64 and percent-encoding solve different problems. How each works byte by byte, which Base64 variant to pick, and when to use each. Read guide →
- JWT Explained: Header, Payload, Signature and Decoding How a JWT is built from header, payload and signature, how to decode one in JavaScript, PHP or Python, and mistakes that make JWTs unsafe. Read guide →
Answers
Base64 decoding questions
Why do I get garbled characters after decoding?
The bytes are probably not UTF-8 text. They may be binary data (paste an image into Base64 to Image) or text in another encoding such as Latin-1, in which case check what the sender used.
Does it accept URL-safe Base64?
Yes. The decoder maps - and _ back to + and / and restores missing = padding before decoding, so a JWT segment or a base64url token pastes as it is. A data: URL prefix is stripped too.
Can I decode part of a JWT here?
You can, since each segment is base64url. The JWT Decoder does all three segments in one step and pretty-prints the header and payload as JSON.
What causes an "invalid character" error?
A character outside both Base64 alphabets, most often surrounding quotes, a trailing comma or part of a JSON field that came along with the copy. Spaces, line breaks, a data: prefix and URL-safe - and _ are all handled, so paste the encoded value and drop the rest.
Is the decoded data sent to a server?
No. Decoding uses the browser's built-in atob() function in this tab, so nothing leaves your device.