FormatterHQ

Base64 Decode

Decode Base64 and Base64URL strings to readable text. Binary results are shown as a hex dump with the file type detected and a download button.

Loading tool…
Ready.

How to use the Base64 Decode

  1. Type or paste into the Base64 box, or click Sample. You can also drop a file on a box or use its Open file button.
  2. The Text box updates live as you type. It works both ways — edit the Text side to convert back, or click ⇄ Swap to exchange the sides.
  3. Alphabet and Wrap lines at 76 chars (MIME) in the options bar above the editors only affect the reverse direction — the Base64 output you get when you type in the Text box.
  4. Use Copy or Download on either box to take the result, or Clear to start again.

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):

SGVsbG8sIFdvcmxkIQ

Decoded 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 %3D from 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 withUsually means
eyJJSON — {" encoded; common in JWTs
iVBORw0KGgoPNG image
/9j/JPEG image
JVBERPDF document (%PDF)
H4sIgzip-compressed data
PD94bWwgXML 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.

Frequently asked questions

Why does my decoded text show strange characters?
The data is either binary (such as an image or compressed file) or text in an encoding other than UTF-8. In both cases the tool switches to a hex dump and offers a download.
Can it decode Base64 without = padding?
Yes. Padding is optional; the decoder adds it back automatically before decoding.
Does it support Base64URL?
Yes. The URL-safe characters - and _ are converted to + and / automatically, so Base64URL strings such as JWT segments decode directly.
How do I save the decoded file?
When the result is binary, a note appears under the decoded output with a Download button. The file extension is chosen from the detected file type, such as .png or .pdf.
Is decoding Base64 safe?
Decoding itself is harmless and happens locally. Be careful with what you do next: do not open decoded files from untrusted sources without scanning them.

Last updated October 3, 2026

Guides

Related tools