Base64 → Text
Paste base64 below, get the decoded UTF-8 text. Whitespace, line breaks, and URL-safe variants all work.
How the decoder works
- Strip whitespace (spaces, tabs, newlines).
- Replace
-with+and_with/(URL-safe normalization). - Pad with
=until length is a multiple of 4. - Run through
atob()to get a binary-string of the bytes. - Convert to a
Uint8Arrayand decode as UTF-8 withTextDecoder.
Steps 1–4 produce bytes; step 5 produces text. If the bytes aren't valid UTF-8, step 5 throws a "decode error" — that's usually a sign the input was binary data, not text.
Common things to decode
- HTTP Basic Auth headers. Strip the
Basicprefix, paste the rest. - JWT parts. The header and payload (first two segments) are URL-safe base64 JSON. The signature is binary — don't expect it to decode to text.
- Email attachments. The base64 body of a MIME part decodes back to the original file bytes (not text — use the file decoder).
- Kubernetes secrets.
kubectl get secret X -o yamlshows base64-encoded values. Decode here to see them in plain text. - Configuration values. Many cloud / CI systems base64-encode env vars and certs.
What "decode error" means
Two distinct failure modes:
- "Invalid character" — the input has a character outside the base64 alphabet. Common causes: a stray space, an HTML entity (
&), or copy-paste artifacts. Trim and retry. - "Invalid UTF-8" — the base64 decoded successfully but the bytes aren't a valid UTF-8 string. The input was binary (an image, audio, encrypted blob), not text. Use the file decoder to write the bytes to a file instead.
In code
// JavaScript (UTF-8 safe)
const bytes = Uint8Array.from(atob(b64.replace(/-/g,"+").replace(/_/g,"/")),
c => c.charCodeAt(0));
const text = new TextDecoder().decode(bytes);
// JavaScript (Node 16+)
Buffer.from(b64, "base64").toString("utf-8");
Buffer.from(b64, "base64url").toString("utf-8");
// Python
import base64
base64.b64decode(b64).decode()
base64.urlsafe_b64decode(b64 + "==").decode() // urlsafe needs padding sometimes
// Bash
echo "$b64" | base64 -d
// Go
import "encoding/base64"
data, _ := base64.StdEncoding.DecodeString(b64) FAQ
It says decode error — what's wrong?
The most common causes: (1) the input isn't valid base64 (extra characters, wrong alphabet), (2) the input is base64 but the bytes aren't valid UTF-8 text (it's binary data), (3) padding is missing on a strict decoder. Try removing whitespace, or use the file decoder for binary content.
Does it accept URL-safe base64?
Yes. The decoder normalizes -/_ back to +// automatically. Both forms decode to the same bytes.
Can I decode something that has line breaks?
Yes. The decoder strips whitespace before decoding. MIME-style 76-character line wrapping is handled.
How do I decode a JWT payload?
Split the JWT on ., take the second part (the payload), and paste here. It's URL-safe base64 of a JSON string. For full JWT inspection (including signature verification), use our JWT decoder.