B6
100% Client-SideAbout
Back to tool
Guide6 min read

How to Decode Base64

A practical guide to decoding Base64 strings back to plain text, images, and binary files — online, in JavaScript, Python, Node.js, and the terminal.

Want to decode right now?

Paste your Base64 string into the free online tool — instant results, no upload.

Decode Now

What does “decode Base64” mean?

Base64 is a way to represent binary data — bytes — as a safe string of ASCII characters. Decoding Base64 reverses this process: it takes the encoded string and converts it back to the original data, whether that's plain text, an image, a PDF, or any other file.

You can identify a Base64-encoded string by its character set: only the letters A–Z and a–z, the digits 0–9, and the symbols + and / (or - and _ in URL-safe Base64). Strings often end with one or two = padding characters.

Common situations where you'll encounter Base64 data: email attachments (MIME encoding), JWT tokens, API responses containing binary data, HTML data: URIs, and environment variables storing binary secrets.

Decode Base64 online — step by step

01

Open the Base64 decoder

Go to Base64 Tool and make sure the Text tab is selected. No sign-up or installation required — everything runs in your browser.

02

Switch to Decode mode

Click the Decode button (or toggle) above the input area. The direction indicator will show an arrow pointing from Base64 → Plain Text.

03

Paste your Base64 string

Paste the Base64-encoded string into the left text area. The decoded output appears instantly on the right — no button to press. If your string uses URL-safe characters (- and _ instead of + and /), enable the URL-Safe toggle first.

04

Copy the decoded text

Click the Copy button next to the output to copy the decoded result to your clipboard. For images encoded as data URIs, use the Image tab instead to preview and download the decoded file.

Decode Base64 in code

Decode Base64 in JavaScript (browser)

The built-in atob() function decodes Base64 strings in the browser, but only handles Latin-1 characters. Use TextDecoder for full UTF-8 support:

// Simple Latin-1 decode (built-in)
const decoded = atob("SGVsbG8sIFdvcmxkIQ==");
// → "Hello, World!"

// UTF-8 safe decode (handles emoji and non-ASCII)
function decodeBase64(str) {
  const bytes = Uint8Array.from(atob(str), c => c.charCodeAt(0));
  return new TextDecoder().decode(bytes);
}
decodeBase64("8J+YgA=="); // → "😀"

Decode Base64 in Node.js

Node.js Buffer handles Base64 decoding natively without any imports:

// Decode Base64 string to UTF-8 text
const encoded = "SGVsbG8sIFdvcmxkIQ==";
const decoded = Buffer.from(encoded, "base64").toString("utf8");
console.log(decoded); // → "Hello, World!"

// Decode to binary file
const fs = require("fs");
const fileData = Buffer.from(base64String, "base64");
fs.writeFileSync("output.png", fileData);

Decode Base64 in Python

Python's standard library includes Base64 decoding in the base64 module:

import base64

# Decode Base64 string to bytes, then to UTF-8 text
encoded = "SGVsbG8sIFdvcmxkIQ=="
decoded = base64.b64decode(encoded).decode("utf-8")
print(decoded)  # → Hello, World!

# Decode URL-safe Base64 (uses - and _ instead of + and /)
url_safe = "SGVsbG8sIFdvcmxkIQ"
decoded = base64.urlsafe_b64decode(url_safe + "==").decode("utf-8")

Decode Base64 in the terminal (macOS/Linux)

Use the built-in base64 command to decode strings or files from the command line:

# Decode a Base64 string
echo "SGVsbG8sIFdvcmxkIQ==" | base64 --decode
# → Hello, World!

# Decode a Base64 file to binary
base64 --decode input.b64 > output.png

Common Base64 decoding errors

Invalid Base64 string

Why it happens: The string contains characters outside the Base64 alphabet (A–Z, a–z, 0–9, +, /, =).

Fix: Check for spaces, line breaks, or extra characters. If the string uses - or _, enable URL-safe mode.

Incorrect padding

Why it happens: Base64 strings must have a length divisible by 4. Missing = padding characters cause this error.

Fix: Add = characters to the end until the length is divisible by 4, or use a tool that handles padding automatically.

Garbled / mojibake output

Why it happens: The decoder is treating UTF-8 encoded data as Latin-1 (e.g., using atob() directly).

Fix: Use a UTF-8 aware decoder — this tool uses TextDecoder internally, so it handles all Unicode correctly.

Output looks like binary gibberish

Why it happens: The Base64 string encodes a binary file (image, PDF, zip), not text.

Fix: Use the Image or File tab in the tool to decode binary Base64 and download the result as a file.

Your data stays private

All decoding happens entirely in your browser using the TextDecoder Web API. No data is ever sent to a server — making this tool safe for decoding sensitive content like API keys, tokens, credentials, and private documents.

Ready to decode your Base64 string?

Free, instant, and 100% private — nothing is ever uploaded to a server.

Open Base64 Decoder