Base64 decode to text or binary
The Base64 decode tool converts Base64 back into the original bytes. If those bytes are valid UTF-8 text, you see the text. If they are binary — an image, a PDF, a compressed stream — you get a hex dump instead, the detected file type, and a Download button to save the file with the right extension.
What the decoder accepts
Base64 comes in several dialects, and real-world strings are often slightly damaged by copying. The decoder normalises the input before decoding:
- Standard and URL-safe alphabets.
-and_are treated as+and/, so JWT segments and Base64URL tokens decode directly. - Missing padding.
=characters are optional; they are added back automatically. - Whitespace and line breaks from MIME-wrapped emails or PEM files are ignored.
- Data URIs. A prefix such as
data:image/png;base64,is stripped.
Example
Base64 input (padding removed):
SGVsbG8sIFdvcmxkIQDecoded text:
Hello, World!A small PNG image decodes to a hex dump that starts with the PNG signature:
00000000 89 50 4e 47 0d 0a 1a 0a 00 00 00 0d 49 48 44 52 .PNG........IHDR
00000010 00 00 00 01 00 00 00 01 08 06 00 00 00 1f 15 c4 ................
File type detection
For binary output, the decoder checks the first bytes (“magic numbers”) to recognise PNG, JPEG, GIF, WebP, BMP, ICO, TIFF, PDF, MP3, ZIP and gzip data, and names the download accordingly. That makes it easy to recover an attachment or an embedded image from an API response or an email source. To view an image directly, use Base64 to Image.
Error messages explained
- “unexpected character”. The string contains something outside the Base64 alphabet — often a quote, a comma, a backslash from JSON escaping, or
%3Dfrom URL encoding. Remove it, or URL-decode the value first. - “the length is not valid (data looks truncated)”. One character too many or too few: a Base64 string can never have a length of 4n + 1. The value was probably cut off when copying.
- A hex dump instead of text. Not an error: the decoded bytes are not valid UTF-8. They may be binary data or text in another encoding such as UTF-16 or Windows-1252.
Base64 decoding is lossless: the bytes you get back are exactly the bytes that were encoded. For binary data, the Download button saves those bytes unchanged, so the file’s checksums match the original. Decoded text is shown in an editor that stores every line break as a line feed, so text copied or downloaded from it has LF line endings even if the original used Windows CRLF, and a leading UTF-8 byte order mark is dropped.
Recognising Base64 at a glance
| Starts with | Usually means |
|---|---|
eyJ | JSON — {" encoded; common in JWTs |
iVBORw0KGgo | PNG image |
/9j/ | JPEG image |
JVBER | PDF document (%PDF) |
H4sI | gzip-compressed data |
PD94bWwg | XML declaration (<?xml ) |
For JWTs, the JWT Decoder splits and decodes all parts at once, and gzip data can be unpacked with Gzip Decompress.
Decoding in code
JavaScript: new TextDecoder().decode(Uint8Array.from(atob(b64), c => c.charCodeAt(0))) handles UTF-8 correctly, whereas atob alone returns Latin-1 characters. Node.js: Buffer.from(b64, 'base64').toString('utf8'). Python: base64.b64decode(b64).decode('utf-8'), or urlsafe_b64decode for Base64URL (Python requires correct padding). Shell: base64 -d (-D on older macOS).
To encode data, use the Base64 Encoder. Decoding runs in your browser, so tokens and files you paste stay on your device unless you click Save & Share, which stores the input on our server so the link can reopen it.