What is a Base64 Encoder/Decoder?
Base64 is an encoding scheme that converts binary or text data into a set of 64 ASCII characters (A–Z, a–z, 0–9, + and /), making it safe to embed in text-based formats like JSON, HTML, email and URLs. Encoding 'Hi' produces 'SGk='. It is reversible encoding — not encryption.
Where Base64 shows up in real work
Once you start looking, Base64 is everywhere on the web. Data URIs embed small images and fonts directly into CSS and HTML as Base64 strings. HTTP Basic Authentication sends credentials as a Base64-encoded username:password pair in a header. JSON Web Tokens carry their header, payload and signature as three Base64url segments joined by dots. Email attachments travel as Base64 inside MIME messages, and countless APIs accept binary payloads — avatars, signatures, PDFs — as Base64 inside JSON bodies. Kubernetes secrets, TLS certificates in PEM files, and the .p12 bundles mobile developers wrestle with are all Base64 underneath.
The common thread is that all of these channels were built for text. Base64 is the bridge that lets arbitrary bytes cross text-only bridges without corruption: every possible byte value maps into a 64-character alphabet that no mail server, proxy or parser will mangle, strip or reinterpret along the way.
Why Base64 output grows by about 33%
Base64 works in groups of three bytes — 24 bits — and splits each group into four 6-bit chunks, each mapped to one printable character. Four characters represent what three bytes held, so the output is always 4/3 the size of the input: 33% larger, plus up to two padding characters (= or ==) to round the length to a multiple of four.
That overhead is the price of text safety, and it is why Base64 is a terrible compression strategy: encoding a file makes it bigger, not smaller. For large assets, serve the binary directly and reserve Base64 for small embeds where one fewer network request wins.
How Base64 encoding actually works, step by step
The algorithm is simple enough to do by hand. Take the text "Hi": its bytes are 01001000 and 01101001 in binary. Concatenate them and split into 6-bit groups: 010010, 000110, 1001 — padding the final group with zeros to reach six bits. Each 6-bit value (0–63) indexes the Base64 alphabet A–Z, a–z, 0–9, +, /: 16 is S, 6 is G, and the padded group gives k, with an = sign marking the short group. Result: SGk=.
Decoding is the exact mirror — each character maps back to 6 bits, the bit stream regroups into 8-bit bytes, and the UTF-8 bytes become text again. Because the mapping is fixed and public, Base64 obscures nothing; it only reshapes data. That is why this tool warns against treating it as protection: "SGVjcmV0" is not a hidden password, it is the word "Secret" wearing a costume.
The URL-safe variant and UTF-8 pitfalls
Standard Base64 uses + and / — both characters with special meaning in URLs and filenames. The URL-safe variant (Base64url, RFC 4648) swaps them for - and _ and typically omits the = padding, producing strings that survive query parameters, JWT segments and file systems untouched. The toggle above switches this tool between the two alphabets.
The second pitfall is character encoding. JavaScript's btoa() only accepts byte-sized characters, so naive tools throw or corrupt data on anything non-ASCII. This tool encodes text as UTF-8 first, which is why café becomes Y2Fmw6k= and emoji round-trip perfectly. If another tool ever shows you mojibake like café after decoding, it decoded UTF-8 bytes as Latin-1 — the data was fine, the decoding was not.
Padding is the third small gotcha. Strict decoders reject Base64 whose length is not a multiple of four, but URL-safe producers routinely omit the = padding to keep tokens compact. When you paste an unpadded string here, the decoder restores the missing padding automatically before validating — one less reason to edit the input by hand.
Why use our base64 encoder/decoder?
True UTF-8 support
Emoji, accented text and CJK characters encode and decode correctly — no "café" mojibake, ever.
URL-safe mode
One toggle swaps +/ for -_ and strips padding — perfect for tokens, filenames and query parameters.
Instant round-trips
Live conversion as you type, plus a Swap button to flip direction and verify results in one click.
Fully private
Decode JWT payloads and auth headers without leaking them — nothing you paste ever leaves your browser.
Base64 Encoder/Decoder examples
| Input | Direction | Output |
|---|---|---|
| Hello | Encode | SGVsbG8= |
| café ☕ | Encode (UTF-8) | Y2Fmw6kg4piV |
| UXVpY2tLaXQ= | Decode | QuickKit |
| Hello | Encode · URL-safe | SGVsbG8 (padding stripped) |
| eyJhbGciOiJIUzI1NiJ9 | Decode · URL-safe | {"alg":"HS256"} |
How to use this base64 encoder/decoder
Paste your text (to encode) or Base64 string (to decode) into the input.
Select Encode or Decode with the direction control.
Toggle URL-safe if the result is going into a URL, filename or JWT.
Copy the output — use Swap to verify a round-trip back to the original.
Common mistakes to avoid
Treating Base64 as encryption. — Anyone can decode Base64 — it has no key and provides no security. Never use it to "protect" secrets, passwords or tokens.
Decoding UTF-8 as Latin-1 and getting mojibake. — If é becomes é, the bytes were decoded with the wrong charset. This tool decodes UTF-8 properly so é and emoji survive.
Pasting URL-safe Base64 into strict decoders. — The - and _ characters are invalid in standard Base64. Enable URL-safe mode and the tool converts the alphabet and restores padding automatically.
Base64-encoding files to "compress" them. — Base64 makes data roughly 33% larger, never smaller. Compress with gzip or brotli first if size matters.