Skip to content
gohacks.dev
Web

Base64 Encoder and Decoder

Encode text to Base64 or decode it back, with UTF-8 handled correctly and an option for the URL-safe alphabet used in JWTs.

Free · No sign-up · Your inputs stay in your browser

Input

Encode text as Base64

Output

28 characters

Runs in this browser. Nothing you paste is sent to a server.

Base64 is an encoding, not encryption

Anyone can decode it. It exists to carry bytes through channels that only accept text: email bodies, JSON fields, data URLs and HTTP Basic authentication headers. Never use it to hide a secret.

Standard versus URL-safe

The standard alphabet uses + and /, which have meaning in URLs. The URL-safe alphabet from RFC 4648 section 5 swaps them for - and _, and JWTs also drop the = padding.

Why btoa() throws on emoji

The browser's btoa() only accepts characters in the Latin-1 range. This tool encodes the text as UTF-8 first, which is also what PHP's base64_encode() and Node's Buffer.from(text).toString("base64") do with a UTF-8 string.

Share

Frequently asked questions

How much bigger does Base64 make data?
About 33 percent: every 3 bytes become 4 characters, plus up to two = characters of padding.
Why does my decoded output look like garbage?
The data was probably binary, such as an image or a gzip stream, rather than text. This tool only shows output that is valid UTF-8 text.
Is what I paste sent anywhere?
No. The tool runs entirely in your browser with JavaScript. Nothing you type or paste is sent to our server or stored.

Keep planning

Similar tools