Base64 Encoder & Decoder
Type or paste text on either side. The other side updates as you type. UTF-8 safe by default — emoji, CJK, accents all roundtrip correctly.
What this does
- Two-way live conversion. Type in either pane; the other auto-updates.
- UTF-8 safe. Unlike a plain
btoa()call, this tool encodes the text as UTF-8 bytes first, so non-Latin characters survive the roundtrip. - URL-safe variant. Tick "URL-safe" to swap
+→-and/→_, the form used in JWT and URL query strings. - Strip padding. Drop trailing
=for compact output (the decoder accepts both forms). - Line wrap. Insert line breaks every 76 characters, MIME-style. Useful for email and PEM-style text.
Why client-side
Most "Base64 encoder" sites upload your text to their server, encode it there, and return the result. That's a privacy and bandwidth tradeoff for nothing — every modern browser has built-in base64 functions.
This tool uses btoa() (encode) and atob()
(decode) plus the TextEncoder/TextDecoder
APIs for UTF-8. Total JS for the page is under 10 KB. Nothing leaves
your browser.
Common use cases
- HTTP Basic Auth. The
Authorization: Basicheader takesbase64(user:pass). - Data URIs. Inline images, fonts, or PDFs in HTML/CSS use
data:image/png;base64,.... See the file converter. - Email attachments. MIME wraps binary attachments as base64.
- Configuration values. Kubernetes secrets, env vars, and many config formats expect base64-encoded credentials or certs.
- Storing binary in JSON. JSON has no binary type — base64 is the conventional escape.
- JWT. The three parts of a JWT are base64url-encoded JSON. See our JWT decoder.
Programmatic equivalents
// JavaScript / Node
btoa(unescape(encodeURIComponent(text))); // encode (UTF-8 safe)
decodeURIComponent(escape(atob(base64))); // decode
// Python
import base64
base64.b64encode(text.encode("utf-8")).decode()
base64.b64decode(b64_string).decode("utf-8")
// Bash
echo -n "hello" | base64
echo -n "aGVsbG8=" | base64 -d
// Go
import "encoding/base64"
base64.StdEncoding.EncodeToString([]byte(s))
Common pitfalls
btoaalone breaks on Unicode.btoa("café")throws. Always UTF-8-encode first.- URL-safe is not interchangeable. A URL-safe base64 string fails strict decoders unless you replace
-/_back to+//first. - Padding requirements vary. Some decoders require trailing
=, others reject it. RFC 4648 says padding is optional for url-safe encoding. - Don't use base64 as encryption. It's encoding, not cryptography. Anyone can decode it.
FAQ
Is the text I paste sent anywhere?
No. Encoding and decoding both run in your browser via the built-in btoa/atob APIs plus TextEncoder for UTF-8 handling. Open DevTools → Network and verify — no requests are made.
Why does my emoji break with plain btoa?
btoa only handles Latin-1 characters. For arbitrary Unicode (emoji, CJK, accents), the input must first be UTF-8 encoded to bytes. This tool does that — TextEncoder converts the string to UTF-8 bytes, then base64 encodes the bytes. Every other roundtrip works.
What's the size overhead?
Base64 encodes 3 input bytes as 4 output characters. So output is 4/3 ≈ 33% larger than input. Add ~1% for newline wrapping if enabled.
URL-safe — what's different?
Standard base64 uses + and /, which need URL-encoding. URL-safe (base64url, RFC 4648 §5) uses - and _ instead. Useful for JWT, query strings, and filenames. See the comparison.
Can I decode binary data?
Decoding works on any base64 input, but if the result isn't valid UTF-8 text (e.g. a PNG or binary protocol message), the text pane will show a decode error. Use the file converter for binary content.