Base64 Decode

Paste a Base64 string and get the original text or bytes back. Line breaks, URL-safe characters, missing padding and data: prefixes are handled automatically, and errors point to the exact character.

Runs entirely in your browser. Nothing is uploaded.

How to use

  1. Paste the Base64 string into the input, or click Open file to load a file that contains Base64 text.
  2. Keep text output and choose the character set (UTF-8 by default), or switch the output to hex for binary data.
  3. If decoding fails, read the error message: it gives the position of the first invalid character.
  4. 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 -----BEGIN and -----END lines 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 withDecoded content
iVBORw0KGgoPNG image
/9j/JPEG image
R0lGODGIF image
JVBERi0PDF document
UEsDBZIP archive, including DOCX, XLSX and JAR
H4sIgzip-compressed data
eyJJSON 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 PNG or PK near 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

AlphabetA-Z a-z 0-9 + /
Output size4 characters per 3 bytes (about 133%)
Padding= to a multiple of 4 characters
StandardRFC 4648 section 4
Case sensitiveYes

Examples

Input (UTF-8)Output
Hello, World!SGVsbG8sIFdvcmxkIQ==
Base64.isQmFzZTY0Lmlz
你好5L2g5aW9

Frequently asked questions

Why do I get an invalid character error?
The input contains something outside the Base64 alphabet, such as quotation marks, a backslash, or percent escapes like %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?
Yes. The decoder does not need the trailing = signs, so unpadded strings from JWTs, URLs and APIs decode normally.
Why is the output wrong after copying Base64 from a URL?
When Base64 is placed in a query string without escaping, form decoding often turns every + 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?
Use Base64 to Image to preview and download pictures, or Base64 to File for PDFs, archives, audio and other files. Both detect the file type from its first bytes.
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.