Base64 Encoder & Decoder
Encode text to Base64 or decode Base64 back to text — with proper UTF-8 handling and an optional URL-safe variant.
What Base64 is used for
- Embedding images in HTML/CSS —
data:image/png;base64,...URLs - Encoding credentials in HTTP headers — Basic Auth uses Base64
- JWT tokens — header and payload are URL-safe Base64
- Email attachments — MIME uses Base64 for binary parts
- Storing binary data in JSON/XML — when only text fields are allowed
Standard vs. URL-safe Base64
Standard Base64 uses + and / for the last two characters of its alphabet. Both have special meaning in URLs (they need percent-encoding), so RFC 4648 defines a URL-safe variant that uses - and _ instead. Padding (=) is sometimes also stripped, since the original byte length can be inferred from the encoded length.
UTF-8 and Base64
Base64 encodes bytes, not characters. To encode a string, you first encode it as bytes — almost always UTF-8 today. The browser's built-in btoa() doesn't do this conversion and throws on non-Latin-1 characters. This tool uses TextEncoder to UTF-8 encode first, so you get the same Base64 output that Python's base64.b64encode(s.encode('utf-8')) produces.
Frequently asked questions
Why does the encoded text get longer?
Base64 encodes 3 bytes (24 bits) into 4 ASCII characters (32 bits), so the output is roughly 4/3 the length of the input — about a 33% increase. With padding it's always rounded up to a multiple of 4.
Is Base64 encryption?
No. Base64 is reversible and uses no key. It's an encoding for safe transport, not a security mechanism. Anyone can decode it instantly.
Is my input sent anywhere?
No. The encoding and decoding happen locally in your browser using TextEncoder, TextDecoder, and btoa/atob. No network requests.