Base64 Encoder & Decoder
Encode text to Base64 or decode Base64 back to text — Unicode-safe, with clear errors when decoding fails. Runs entirely in your browser.
- Free — No signup required
- Instant — Results update as you type
- Private — Processed in your browser
Base64 turns any sequence of bytes into text drawn from 64 safe characters, so binary or non-ASCII data can travel through systems that only understand plain ASCII: email bodies, JSON strings, HTTP headers, configuration files. This tool encodes and decodes text in both directions, and does so correctly for every Unicode character, which the browser's raw btoa and atob functions do not.
How it works
In Encode mode your text is first converted to UTF-8 bytes with TextEncoder, then those bytes are Base64-encoded in 32 KB chunks so that very long inputs do not overflow the call stack. The output uses the standard alphabet (A–Z, a–z, 0–9, +, /) with = padding, as defined in RFC 4648 section 4.
In Decode mode the Base64 is turned back into bytes with atob, then decoded as UTF-8 in strict mode. Two different errors can appear:
- That doesn't look like valid Base64 means the input contains characters outside the alphabet, or its length is impossible. Whitespace and line breaks are tolerated, and missing padding is forgiven, but the URL-safe variant with
-and_is not; replace those with+and/first. - The decoded data isn't valid UTF-8 text means the Base64 was fine but the bytes are not text. That is what you see when you decode an image, a certificate in DER form or a compressed blob. The tool is deliberately text-only; it will not offer a mangled rendering of binary data.
Everything runs locally, and the result updates on each keystroke.
Things Base64 is and is not
Base64 is an encoding, not encryption. Anyone can reverse it in a fraction of a second, and it offers no integrity protection either. If you see credentials "protected" by Base64, treat them as plain text. The HTTP Basic authentication header is the classic example: Basic dXNlcjpwYXNz is simply user:pass.
It is also not compact. Every 3 bytes become 4 characters, so output is about 33% larger than the input, plus padding. Embedding large files in JSON or HTML this way costs bandwidth; for anything above a few kilobytes prefer a separate binary request.
The = padding carries no data. Some producers omit it, and RFC 7515 (JSON Web Signatures) requires it to be omitted in the URL-safe form used by JWTs. This is why a JWT segment pasted here needs a small edit before it decodes; the JWT decoder handles that variant for you.
Command-line equivalent
The same operations on Linux and macOS, with -n to stop echo appending a newline that would end up inside the encoding:
echo -n 'héllo wörld' | base64 # aMOpbGxvIHfDtnJsZA==
echo 'aMOpbGxvIHfDtnJsZA==' | base64 -d # héllo wörld
The base64 utility on macOS uses -D for decoding in older versions; --decode works on both.
Learn more
Base64 shows up wherever a protocol has to carry bytes inside text. REST API design discusses when to embed binary data in a JSON body and when to link to it instead, and the guide to OAuth 2.0 walks through the client-credentials header and the URL-safe encoding that tokens use. For percent-encoding, the other scheme that makes text safe for URLs, see the URL encoder.
FAQ
- Does this handle emoji and non-English text correctly?
- Yes. Text is converted to UTF-8 bytes before Base64 encoding (and decoded back the same way), so accented characters, emoji and non-Latin scripts round-trip correctly — unlike a naive btoa/atob call, which breaks on any character outside the Latin-1 range.
- Why does decoding say my input is invalid?
- Base64 uses a specific 64-character alphabet plus = padding. If the input contains other characters, has incorrect length, or decodes to a byte sequence that isn't valid UTF-8 text, you'll see a specific error explaining which of those went wrong.
- Is my data uploaded to a server?
- No. Encoding and decoding happen entirely in your browser.