How to use
- Paste the Base64 string into the input, or click Open file to load a file that contains Base64 text.
- Keep text output and choose the character set (UTF-8 by default), or switch the output to hex for binary data.
- If decoding fails, read the error message: it gives the position of the first invalid character.
- Copy the decoded result or download it.
What the decoder accepts
Decoding reverses the encoding: each character is mapped back to its 6-bit value and every four characters become three bytes. Base64 found in the wild is rarely clean, so this decoder is forgiving:
- Spaces and line breaks are ignored, so wrapped MIME bodies and PEM blocks can be pasted as they are. Delete the
-----BEGINand-----ENDlines first, though: their letters and dashes are valid Base64 characters and would be decoded as data. - URL-safe input with
-and_decodes just like standard Base64 with+and/. - Missing padding is fine. Only a length of 4n + 1 characters is rejected, because a single leftover character cannot form a byte; it usually means the string was cut off.
- Data URIs work too: a leading
data:...;base64,prefix is removed before decoding.
Text or binary output
The result of decoding is always a sequence of bytes. If the original was text, keep text output and pick its character set. If it was an image, PDF, archive, key or ciphertext, no character set will make it readable: switch the output to hex to inspect the bytes, or open Base64 to File or Base64 to Image to preview and save it. The first characters often give the content away:
| Base64 starts with | Decoded content |
|---|---|
iVBORw0KGgo | PNG image |
/9j/ | JPEG image |
R0lGOD | GIF image |
JVBERi0 | PDF document |
UEsDB | ZIP archive, including DOCX, XLSX and JAR |
H4sI | gzip-compressed data |
eyJ | JSON object, such as a JWT header |
Why the decoded text looks garbled
- Wrong character set. UTF-8 text read as Windows-1252 turns é into
é, and GBK or Shift_JIS text read as UTF-8 shows replacement characters (�). Select the charset the text was written in. - Binary data. Random symbols with the odd readable fragment, such as
PNGorPKnear the start, mean the content is a file rather than text. - Compressed or encrypted data. gzip streams, Protocol Buffers and ciphertext decode correctly but are not text. Hex output shows what is really there.
- Double encoding. If the output is itself Base64, paste it back into the input and decode it a second time.
Decoding Base64 in code
# Python
base64.b64decode(s).decode('utf-8')
// Node.js (also accepts URL-safe input)
Buffer.from(s, 'base64').toString('utf8')
// Browser: atob() returns one character per byte, so decode UTF-8 afterwards
new TextDecoder().decode(Uint8Array.from(atob(s), c => c.charCodeAt(0)))
# Linux and macOS shell
echo 'SGVsbG8=' | base64 --decode
Specification
| Alphabet | A-Z a-z 0-9 + / |
|---|---|
| Output size | 4 characters per 3 bytes (about 133%) |
| Padding | = to a multiple of 4 characters |
| Standard | RFC 4648 section 4 |
| Case sensitive | Yes |
Examples
| Input (UTF-8) | Output |
|---|---|
Hello, World! | SGVsbG8sIFdvcmxkIQ== |
Base64.is | QmFzZTY0Lmlz |
你好 | 5L2g5aW9 |
Frequently asked questions
Why do I get an invalid character error?
%2B and %3D copied from a URL. Remove the quotes or URL-decode the string first. The error message shows the position of the first offending character.Can I decode Base64 without padding?
= signs, so unpadded strings from JWTs, URLs and APIs decode normally.Why is the output wrong after copying Base64 from a URL?
+ into a space. Spaces are ignored here, so those characters are lost. Replace the spaces with + before decoding, and use Base64URL for values that travel in URLs.How do I decode Base64 to an image or file?
Is my Base64 sent to a server?
No. Decoding runs in your browser with JavaScript and the input never leaves your device, which matters when you decode tokens, configuration secrets or personal data.