Home / Developer tools / Base64 decode

Base64 Decode

Paste Base64 and read the decoded text, or download the decoded data as a file if it is binary. Missing padding, line breaks and the URL-safe alphabet are handled for you.

Try:

Everything runs in your browser. Your data is not sent to our server.

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. SGVsbG8 is decoded the same as SGVsbG8=.
  • 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, Basic or Bearer were 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?

Frequently asked questions

How do I decode Base64?

Paste the Base64 into the box. The text appears at once. If the data is binary, press Download file.

Why does my decoded text look like random symbols?

The data is probably binary (an image or archive), or text in a charset other than UTF-8. Use the Base64 to text page and choose another charset, or download the file.

Does the decoder need the = padding?

No. Missing padding is added for you.

Can I decode a Base64 string with line breaks?

Yes. Spaces and line breaks are ignored, so MIME and PEM text work.

Is my data uploaded?

No. Decoding runs in your browser and nothing leaves your device.