Base64 Encoder & Decoder

Type in either box to encode text as Base64 or decode Base64 back into text. UTF-8 safe, with a URL-safe alphabet option.

Alphabet

How to Use

  1. Type or paste text into the top box and the Base64 result appears in the bottom box.
  2. Paste Base64 into the bottom box to decode it in the top box. There's no encode or decode button to pick, and a missing trailing =, stray spaces, or line breaks are all fine.
  3. For JWTs or values going into a URL, choose the URL-safe alphabet: it uses - and _ instead of + and /, and encoding leaves off the = padding.
  4. If the decoded bytes aren't valid UTF-8, the top box still shows what could be read and warns that this may be binary data such as an image or archive, along with a hex preview of the raw bytes.
  5. If something is wrong, the box with the problem shows which character it is, and the other box keeps its last good result. “Select the problem” highlights that part for you.
  6. “Swap” moves the result into the box you typed in. “Clear” empties both boxes.

Where you run into Base64

Base64 does one job: it turns arbitrary bytes into a string made only of letters, digits, and a couple of symbols, so the data can travel through channels that can only handle plain text. In day-to-day work you meet it in places like these:

In every one of these cases, Base64 is only the packaging. What’s inside is anyone’s guess until you unwrap it.

How the encoding works, and why there’s an equals sign at the end

Base64 takes 3 bytes at a time, which is 24 bits, and splits them into four groups of 6 bits. Each group maps to one of 64 characters. So 3 bytes become 4 characters, and the output is one third larger than the input.

Input Bytes Output Characters Why
Man 3 TWFu 4 One complete group, no padding
Ma 2 TWE= 4 One byte short, so one =
M 1 TQ== 4 Two bytes short, so two =
Hello 5 SGVsbG8= 8 The last group has only 2 bytes

The output length is always a multiple of 4, and the = signs fill the gap, so there are never more than two. Padding only keeps the length tidy. The decoder already has enough information without it, which is why many systems leave it out. When decoding, this tool accepts missing = signs, spaces, and line breaks as they are. When encoding, the standard alphabet adds the padding and the URL-safe alphabet doesn’t.

If the input has a problem, the tool tells you which character is the culprit. Three causes are the most common: a character that isn’t in the alphabet, such as mixing the standard and URL-safe alphabets; data that continues after an = sign; and a count of valid characters that leaves a remainder of 1 when divided by 4. That last length can never come from whole bytes, so part of the string was almost certainly cut off when it was copied.

Why btoa fails on Chinese and emoji and mangles accents

The browser’s built-in btoa function only accepts characters that fit in a single byte, which means the Latin-1 range. Chinese text, emoji, and the € sign make it throw an error. Accented letters such as é and ñ get through, but each one is encoded as a single byte, so the result doesn’t match UTF-8. People then work around it in ways that produce garbled output. The correct approach is to convert the text to bytes first and encode those bytes. This tool uses UTF-8 for that step.

Text UTF-8 bytes Base64 Characters
Hello 5 SGVsbG8= 8
日本語 9 5pel5pys6Kqe 12
こんにちは 15 44GT44KT44Gr44Gh44Gv 20
😀 4 8J+YgA== 8

Plain English letters take one byte each, but accented letters such as é take two, most Chinese, Japanese, and Korean characters take three, and emoji usually take four. That is why non-English text produces longer Base64 than you might expect.

Keep in mind that Base64 doesn’t know which character encoding the original text used. If the string was produced from text in an older encoding such as Windows-1252 or Shift_JIS, decoding it as UTF-8 won’t give a valid result. The tool still shows whatever it can read, and warns that the bytes may not be UTF-8. If the data turns out to be a file, the hex preview lists up to the first 64 bytes, and the opening bytes usually reveal the file type:

Opening bytes Base64 starts with File type
89 50 4E 47 iVBORw PNG image
FF D8 FF /9j/ JPEG image
25 50 44 46 2D JVBERi PDF document

Base64 is not encryption, and it’s not hashing

You’ll often see phrases like “Base64 encryption” or “Base64 decrypt” online, and they cause real confusion. Base64 is an encoding. Its rules are public, there is no key, and anyone can reverse it instantly. It looks like gibberish to a person, but that doesn’t make it unreadable to anybody else.

Technique Can it be reversed? Needs a key? What it’s for
Encoding, such as Base64 Yes, by anyone No Fitting data into places that only accept text
Hashing, such as SHA-256 No No Checking whether data has been changed
Encryption, such as AES Only with the key Yes Keeping content away from other people

Three mistakes show up again and again in real projects:

Base64 often shows up next to hashing and encryption, because hash values and ciphertext are also bytes. When they need to go inside JSON or a URL, Base64 turns them into text. In that setup Base64 only makes the data portable, while hashing and encryption do the verifying and the hiding. If you really need to protect content, use encryption such as AES, or the Password-Protect Text tool.

What to check when the result looks wrong

If the decoded output isn’t what you expected, work through these points first:

FAQ

What is Base64 and when is it used?

Base64 represents any data using 64 printable characters (A–Z, a–z, 0–9, +, /), so images, binary data, or text with special symbols can travel safely inside JSON, email, URLs, or source code. Every 3 bytes become 4 characters, so the output is about a third larger. You'll meet it in JWTs, data URIs, and many APIs.

Is Base64 encryption? Can it protect my data?

No. Base64 is an encoding: it follows a public rule, and anyone can decode it without a key. It hides nothing, even though people often call it “Base64 encryption”. To protect content, use real encryption, and never leave a password or personal data merely Base64-encoded.

Will accents, Chinese, Japanese, or emoji get garbled?

No. The tool treats text as UTF-8, so any language and emoji encode and decode correctly. If the Base64 was produced from text in another character encoding, such as Windows-1252, decoding shows garbled characters and the tool warns that the result isn't valid UTF-8.

What's the difference between the standard and URL-safe alphabets?

The standard alphabet uses + and / and pads with =. The URL-safe alphabet uses - and _ instead, so the result can go into a URL without percent-encoding. JWTs use it, and usually drop the = padding too. Every other character is the same. If you pick the wrong alphabet when decoding, the tool points at the first character that doesn't fit.

What does “not valid UTF-8” mean when decoding?

The decoded bytes can't be read as text. Usually the Base64 actually holds binary data such as an image, PDF, or archive, or the original text used an older character encoding. The tool doesn't fail. It still shows the result, with � for unreadable bytes, plus a hex preview of the raw bytes so you can judge. For example, bytes starting with 89 50 4E 47 are a PNG image.