Base64 Encoder and Decoder with UTF-8 Support
Encode plain text to Base64 or decode Base64 back to text
What is Base64?
Base64 is an encoding scheme that represents binary data as printable ASCII characters. It increases size by ~33% and is commonly used in emails, data URIs, and HTTP Basic Auth.
Common uses
- Encoding images in CSS / HTML data URIs
- HTTP Basic Authentication headers
- JWT token payloads
- Email attachments (MIME)
What is Base64 encoding?
Base64 maps arbitrary bytes onto 64 printable ASCII characters (A–Z, a–z, 0–9, + and /) so binary or non-ASCII data can travel safely through systems that only handle plain text — email bodies, JSON strings, HTTP headers, URLs. It is an encoding, not encryption: anyone can reverse it, and it adds roughly 33% to the size. This tool converts in both directions, handles full UTF-8 (emoji, accented characters, CJK text) correctly, and updates the output as you type.
Everything runs in your browser. The text you paste is never uploaded, stored, or logged, so it's safe to decode tokens or payloads that contain credentials or internal data.
When to use it
The most common day-to-day use is decoding: you're staring at a JWT segment, an HTTP Basic Auth header, a Kubernetes Secret value, or a data: URI and want to see what's inside. Paste it in decode mode and read the plain text. Encoding comes up when you need to build one of those same artifacts by hand — an Authorization: Basic header from user:password, a small image or file embedded as a data URI, or a config value that must survive a text-only channel.
The Swap button feeds the current output back in as input and flips the direction, which is handy for verifying a round trip. If you need to share what you're looking at, the "Copy link to this result" button encodes your input and mode into the URL fragment, so a teammate opens the exact same conversion.
Example
Switch to Text → Base64 and type admin:s3cret — the output panel shows YWRtaW46czNjcmV0, which is exactly what goes after "Basic " in an Authorization header. Now hit Swap: the tool flips to decode mode, feeds the Base64 back in, and returns admin:s3cret, proving the round trip. The character counters under each panel show the ~33% size overhead in real time.
Base64 decode in Python, JavaScript, PHP and the command line
The same conversion this page does, in the places you are likely to need it.
Python: base64.b64decode(s).decode("utf-8") decodes and base64.b64encode(text.encode("utf-8")).decode() encodes; use base64.urlsafe_b64decode for URL-safe input. JavaScript in the browser: atob() and btoa() only handle Latin-1, so for real text go through bytes — new TextDecoder().decode(Uint8Array.from(atob(s), c => c.charCodeAt(0))). Node.js is simpler: Buffer.from(s, "base64").toString("utf8") and Buffer.from(text).toString("base64"), with "base64url" accepted as an encoding name. PHP: base64_decode($s) and base64_encode($s); pass true as the second argument to base64_decode to get false on invalid characters instead of having them silently skipped.
Command line: echo 'YWRtaW46czNjcmV0' | base64 -d decodes on Linux and current macOS (older macOS uses -D). To encode, use printf '%s' 'admin:s3cret' | base64 rather than echo — echo appends a newline, which gets encoded too and turns the result into YWRtaW46czNjcmV0Cg==.
If one of these gives a different answer from this page, the cause is almost always a trailing newline, a character set other than UTF-8, or URL-safe input.
Base64 vs base64url, and why Base64 can't be "decrypted"
Standard Base64 (RFC 4648 section 4) uses + and / and pads with =. Those characters mean something inside URLs, so base64url (section 5) swaps them for - and _ and usually drops the padding. JWTs, WebAuthn and most signed-URL schemes use base64url. This page works with the standard alphabet: to decode a base64url string, replace - with + and _ with /, then add = until the length is a multiple of four. To produce base64url, reverse those steps on the output.
Plenty of people search for a "base64 decrypt" tool, and the word gives away a misconception. Base64 has no key, so there is nothing to decrypt — decoding is a fixed table lookup anyone can run, which is exactly what happens when you paste a string here. An API key, password or config secret "protected" only by Base64 is plain text for practical purposes. Kubernetes Secrets are the best-known example: their values are Base64-encoded, not encrypted, so anyone who can read the Secret object can read the value. When data needs protecting, encrypt it (AES-GCM, libsodium, age) and Base64-encode the ciphertext only for transport.
How to use the Base64 Encoder and Decoder with UTF-8 Support tool
- 1
Pick a direction
Choose Text → Base64 to encode or Base64 → Text to decode.
- 2
Paste your input
The output appears instantly as you type — no button to press.
- 3
Swap to verify
The Swap button feeds the output back in with the direction reversed, confirming a clean round trip.
- 4
Copy or share
Copy either panel, or copy a permalink that restores your input and mode for anyone who opens it.
Frequently asked questions
Is Base64 encryption?
No. Base64 is a reversible text encoding with no key and no secrecy — anyone can decode it instantly. Never treat a Base64 string as protected; if you need confidentiality, encrypt first and Base64-encode the ciphertext.
Why does decoding fail with an 'invalid character' error?
The input contains characters outside the Base64 alphabet, has been truncated, or uses the URL-safe variant (- and _ instead of + and /). Whitespace is stripped automatically, but you'll need to swap - back to + and _ back to / for URL-safe strings, and restore any stripped = padding.
Does this handle emoji and non-English text?
Yes. The encoder converts text to UTF-8 bytes before encoding, and the decoder reverses it, so emoji, accented characters and CJK scripts round-trip correctly — unlike a naive btoa() call, which throws on anything outside Latin-1.
Is my data sent to a server?
No. Encoding and decoding run entirely in your browser with JavaScript. Even the shareable permalink keeps your input in the URL fragment, which browsers never send to the server.
Can I decode a Base64 image or PDF here?
This page decodes to text, so binary data like a PNG or PDF comes out as unreadable characters. For images, use the Base64 to Image tool (/tools/base64-to-image), which renders the picture so you can save it; Image to Base64 (/tools/image-to-base64) goes the other way and produces a data URI. For a PDF or another file, decode in code — base64 -d file.b64 > out.pdf on the command line, or Buffer.from(s, "base64") in Node — and write the bytes to disk.
Why does my decoded output look like garbled symbols?
The Base64 almost certainly encodes binary data — an image, a gzip or zip archive, a protobuf message, or ciphertext — rather than text. The decoder tries UTF-8 first and, when the bytes aren't valid UTF-8, shows them one byte per character, which looks like noise. Text in a legacy encoding such as Windows-1252 can also come out slightly wrong.
What does the = at the end of a Base64 string mean?
It's padding. Base64 encodes 3 bytes as 4 characters; when the input length isn't a multiple of 3, the last group is padded — one = means the final group held 2 bytes, == means it held 1. Some formats, base64url in particular, drop the padding; add it back before decoding with strict decoders.
Does the decoder accept line-wrapped Base64 from PEM files or emails?
Yes. All whitespace, including line breaks, is stripped before decoding, so MIME and PEM-style 64- or 76-character lines decode fine. For a PEM file, remove the -----BEGIN ...----- and -----END ...----- lines first; the content between them is DER binary, so expect unreadable output rather than text.
Related on TechLogHub
Related Encoding Tools
URL Encoder and Decoder for Query String Values
Encode or decode URLs and URI components instantly
HTML Entity Encoder and Decoder with Numeric Entities
Encode or decode HTML entities in text
JWT Decoder with Readable exp and iat Claims
Decode and inspect JWT tokens without verification
Binary Translator for UTF-8 Text and Emoji
Translate text to binary and binary to text with UTF-8, plus hex, decimal and octal byte views
Get the next tool before you need it
One email a week: new and trending developer tools, fresh comparisons, and what shipped. Unsubscribe in one click.