Base64 Decoder
Decode Base64 strings back to plain text directly in your browser.
What is a Base64 Decoder?
A Base64 Decoder is a developer utility designed to reverse the Base64 encoding process. It takes a string of 64-character ASCII text—which represents encoded binary data—and translates it back into its original, readable format (such as plain text, JSON, or a binary file). Our online Base64 Decoder operates entirely within your web browser using client-side JavaScript, ensuring that your data is never uploaded to a remote server.
How to Decode Base64 to Text
Decoding a string is incredibly simple using our tool:
- Paste your Base64 encoded string into the Input text area above.
- The tool will automatically detect the input and instantly decode it.
- If the output is valid UTF-8 text, it will appear in the Output area immediately.
- Click Copy to Clipboard to grab the decoded text, or Download as File to save it directly to your device.
If you don't have a string handy, click the Load Sample button to see how the decoder handles Japanese text and emojis.
How Base64 Decoding Works
The decoding algorithm performs the exact inverse of the encoding process. When you paste a string into the decoder:
- The algorithm first strips out any invalid characters, such as spaces or carriage returns, which are often added for formatting (like in MIME email attachments).
- It reads the text characters and uses the standard Base64 index table to translate each character back into a 6-bit binary sequence.
- It combines these 6-bit sequences into a continuous stream of bits.
- It then slices that continuous stream into 8-bit bytes (standard computer bytes).
- Finally, it passes those bytes through a UTF-8 decoder (like the browser's native
TextDecoderAPI) to render the final human-readable text.
Is Base64 Decoding Secure?
Decoding Base64 poses no cryptographic security risks because Base64 itself is not encryption. It is merely a translation format. Anyone with access to a Base64 string can decode it instantly without a password or a decryption key.
However, from an execution standpoint, decoding arbitrary Base64 strings can be risky if you blindly execute the output. If you decode a string and it turns out to be a malicious JavaScript payload, and your application subsequently runs eval() on that output, your system will be compromised (Cross-Site Scripting). Our online tool strictly outputs the decoded data as plain text inside a sandboxed textarea, completely neutralizing any code execution risks.
Why Does Base64 Decoding Fail?
If the decoder displays an "Invalid Base64 input" error, it means the input string violates the mathematical rules of the standard. This usually happens for one of three reasons:
- Invalid Characters: The string contains characters outside the standard 64-character alphabet (A-Z, a-z, 0-9, +, /) that cannot be parsed.
- Missing Padding: The string length is not a multiple of 4, and the required equals sign (
=) padding is missing. Note: our modern decoder gracefully handles most missing padding scenarios. - Non-UTF-8 Output: The string decoded perfectly into raw binary bytes, but those bytes do not represent valid UTF-8 text (for example, if you attempted to decode a Base64 encoded PNG image as text). In this case, the text decoder fails to render the output.
Decoding Base64 in JavaScript
If you are building your own application, you can decode Base64 in JavaScript using the native atob() function. However, just like encoding, atob() fails catastrophically when dealing with multi-byte Unicode characters.
To safely decode a Base64 string into UTF-8 text, you must manually convert the binary string into a typed array and pass it to the TextDecoder API:
// Safe UTF-8 Base64 Decoding
const base64 = "44GT44KT44Gr44Gh44Gv";
const binString = atob(base64);
const bytes = new Uint8Array(binString.length);
for (let i = 0; i < binString.length; i++) {
bytes[i] = binString.charCodeAt(i);
}
const text = new TextDecoder('utf-8').decode(bytes);
console.log(text); // "こんにちは"
FAQ
Can I decode a Base64 string that represents an image?
Not using this text decoder. If a Base64 string represents an image (like a JPEG or PNG), decoding it as text will result in a massive block of unreadable gibberish characters because the underlying bytes do not map to valid letters. To view a Base64 image, you should construct a Data URI (e.g., data:image/png;base64,...) and place it into an <img> tag.
What is Base64URL and can I decode it?
Base64URL is a variant of Base64 used in web URLs and JWTs. It replaces the + character with a hyphen (-) and the / character with an underscore (_) to prevent URL routing errors. Our decoder automatically normalizes these characters, so you can safely decode Base64URL strings here.