KKoumen Tools PRO

Base64 encoder and decoder.

Paste text or drop a file, get Base64 back — with the URL-safe alphabet, 76-column wrapping and data URI prefixes that APIs actually ask for.

Input 0 chars0 bytes UTF-8
Output 0 charsRatio —

The conversion happens in this tab. Careful with one thing though: Base64 is an encoding, not encryption. Anyone holding a Base64 string can read it in one step, so it is the wrong place to hide a password or a token.

Encoding and decoding Base64

Base64 exists for one reason: to move binary data through channels that only accept text. Email, JSON, XML, HTTP headers and data URLs all break if given raw bytes, so the bytes are mapped onto 64 printable characters first and mapped back at the other end.

  1. Pick a direction. Encode takes text or a file and produces Base64. Decode takes Base64 and gives you back the original text or bytes.
  2. Choose the alphabet. Standard Base64 uses + and /. Turn on URL-safe and those become - and _, which is what you need for query strings, filenames and JWT payloads.
  3. Decide on line breaks. MIME and older email systems require a line break every 76 characters. JSON, most APIs and anything compared with === want a single unbroken string.
  4. Copy or swap. Swap takes the output and puts it back in the input with the direction reversed, which is the fastest way to check that a round trip is lossless.

When this comes up

A worked example: what the 33% actually looks like

Base64 turns every three bytes into four characters, so the overhead is fixed at one third — but only once the input is long enough to amortise the padding. Short strings look much worse than the rule suggests:

InputUTF-8 bytesBase64 charactersRatio
Hello, world!13201.54×
A 100-character ASCII string1001361.36×
中文 (two characters)681.33×
A 346 KB photo354,512472,8761.33×

The photo is the number worth internalising. Encoding it produces 472,876 characters — a string larger than the image itself, which then has to be held in memory as text, copied into JSON, escaped again on the way out, and parsed at the other end. That is why binary upload exists. Use a data URI for an icon measured in kilobytes, not for a photograph measured in megabytes.

Note the Chinese case as well: two characters cost six bytes, not two, because UTF-8 spends three bytes on each. The Base64 is eight characters against what a naive byte-per-character assumption would call three. This is exactly where implementations that call btoa on a raw JavaScript string fall over — the string is not bytes, and the conversion has to happen first.

Padding is the detail that breaks integrations. The = characters exist only to round the output up to a multiple of four, and systems disagree about them: some require the padding, some reject it, and some strip it on the way in and expect you to restore it on the way out. If a decoder refuses a string that looks perfectly valid, counting the characters and checking whether the length is divisible by four takes about five seconds and solves it most of the time.

Base64 encoder showing a 45 byte JSON payload encoded to a 60 character URL-safe Base64 string with a 1.33 times ratio
A 45-byte JSON string, encoded in the URL-safe alphabet — 60 characters out, 1.33×, and the ratio is shown so the overhead is never a surprise.

Where Base64 goes wrong

Questions

Is Base64 encryption?

No, and this is the mistake that causes real leaks. Base64 is a reversible encoding with no key, so anyone can decode it in one step. Storing a password or an API token as Base64 offers exactly as much protection as storing it in plain text.

Why does Base64 make text bigger?

Three bytes become four characters, so the output is 4/3 of the input, about 33 percent larger. There is no way around this: the encoding exists to move binary data through text-only channels, not to compress it.

What is the URL-safe variant?

Standard Base64 uses plus and slash, which have special meanings inside a URL and a filename. The URL-safe alphabet replaces plus with minus and slash with underscore, so the result can be pasted into a query string without encoding. JWT tokens use this variant.

Why do Chinese or emoji characters break some decoders?

Older implementations call btoa directly on a JavaScript string, which only works for characters below U+0100. Anything above that is silently corrupted. This tool converts to UTF-8 bytes first, so accented letters, Chinese characters and emoji all survive a round trip.

More text tools

All 6 text tools →

No daily limit on this tool

This one is free with no counter — it runs in your browser and costs nothing to serve. All-Access is for the PDF and image tools, which are free three runs a day.