Base64 Encode and Decode

Type or paste on one side and the other side updates as you go. Text is encoded as UTF-8, so accents, emoji and every script come back exactly as they went in.

How it works

Base64 writes any bytes using only 64 safe characters: A to Z, a to z, 0 to 9, + and /. It exists so binary data can travel through places built for plain text, such as email, JSON, HTML attributes and HTTP headers.

Text is first turned into bytes with UTF-8, the encoding the web uses, and those bytes are encoded. That is why "café" works here when the browser’s own btoa() function throws an error on it.

Decoding runs the other way and checks the result is real text. If the bytes are a file, such as an image, the tool says so instead of showing a screen of garbage. Everything happens on this page; nothing you type is sent anywhere.

How to use it

  1. 1 Pick Encode or Decode.
  2. 2 Type or paste into the first box. The result appears in the second box as you type.
  3. 3 For Base64 that goes into a URL or a file name, turn on URL-safe.
  4. 4 Copy the result or download it as a .txt file. Swap moves the result back into the first box and flips the direction.

Good to know

  • Base64 is not encryption. Anyone can decode it in a second, so never use it to hide a password or a secret.
  • Encoded text is about a third bigger than the original: every 3 bytes become 4 characters.
  • Decoding accepts both alphabets, missing = padding, line breaks, and a whole data: URL.
  • Decoding a picture or a PDF gives bytes that are not text. This tool tells you so; it does not turn Base64 back into files.

Browser support

  • Chrome 94 and later
  • Firefox 93 and later
  • Safari 16.4 and later
  • Edge 94 and later

These are the oldest versions with everything the tool uses. They are worked out from the tool itself, so they change when it does.

Version numbers checked on 2026-09-04.

How "café" becomes Y2Fmw6k=, one bit at a time

Base64 is easiest to understand by doing it once by hand. Take the word "café". A computer cannot store letters, only numbers, so the first step is to turn the text into bytes. The web uses UTF-8 for that, and in UTF-8 the plain letters c, a and f are one byte each: 63, 61 and 66 in hex. The é is not plain ASCII, so it takes two bytes, C3 and A9. Four characters have become five bytes. That one detail is behind most of the confusion about Base64 and Unicode, and we will come back to it.

Base64 then cuts those bytes into groups of three. Three bytes are 24 bits, and 24 bits divide evenly into four groups of 6 bits. Six bits can hold a number from 0 to 63, and each of those 64 numbers is given a character: A to Z are 0 to 25, a to z are 26 to 51, the digits are 52 to 61, and + and / are 62 and 63. The first three bytes, 63 61 66, are the bits 011000 110110 000101 100110, which are the numbers 24, 54, 5 and 38, which are the characters Y, 2, F and m. So "caf" becomes "Y2Fm".

Two bytes are left over, C3 and A9. That is 16 bits, so the encoder adds two zero bits to make 18, which is three groups of six: 48, 58 and 36, or w, 6 and k. One more character would be needed to finish a group of four, and the = sign fills that slot to say "nothing here". The full result is Y2Fmw6k=. You can type "café" into the box above and check it. Every 3 bytes became 4 characters, which is why Base64 is always about a third bigger than what it encodes.

Now the Unicode problem. JavaScript’s built-in btoa() function was written before UTF-8 won. It treats each character as one byte, so it accepts "é" (code 233, which fits in a byte) but produces a different answer from the one above: it encodes the single byte E9, not the two UTF-8 bytes. And for "€" or "😀", whose codes do not fit in a byte at all, it simply throws an error. A server in Python, Go or Java will decode Base64 to bytes and read them as UTF-8, so text encoded the btoa() way arrives mangled. This tool always encodes the UTF-8 bytes, so what you encode here decodes correctly anywhere else.

Base64 has limits that are worth being plain about. It is not encryption and not compression: it hides nothing from anyone who wants to read it, and it makes data bigger, not smaller. It is also not one format but a small family. Standard Base64 uses + and /, which mean something inside a URL, so the URL-safe variant swaps them for - and _ and usually drops the = padding. Some systems also break long Base64 into lines of 76 characters. The decoder here accepts all of those shapes, because Base64 rarely arrives in the form you expected. What it will not do is turn Base64 back into a file: if the bytes are an image or a PDF, it tells you so rather than pretending they are text.

Frequently asked questions

Is Base64 a way to encrypt or hide text?

No. Base64 has no key and no secret. It is a public, reversible way of spelling bytes, and anyone can decode it with this page or one line of code. Use it to carry data, never to protect it.

Why does my browser’s btoa() fail on accents or emoji?

btoa() only accepts characters whose code is below 256, one byte each. "é" fits, but "€" and "😀" do not, so it throws. This tool turns the text into UTF-8 bytes first, which is what nearly every other system expects, so any text works.

What is URL-safe Base64?

The same encoding with two characters swapped: - instead of + and _ instead of /, usually without the = padding at the end. Standard Base64 breaks inside a URL because + and / already mean something there. JSON Web Tokens use the URL-safe form.

Why does the decoder say the result is not UTF-8 text?

Because the Base64 holds bytes that do not spell text in UTF-8, which almost always means it is a file: an image, a PDF, a zip. Showing those bytes as letters would only produce garbage, so the tool tells you instead.

Is what I type sent to a server?

No. The encoding and decoding are plain JavaScript running on this page. You can disconnect from the internet after it loads and it keeps working.

Related tools

Your files are processed on your device and are not uploaded. You can verify this in your browser’s developer tools under the Network tab.