Base64 Encoder & Decoder

Encode text to Base64 or decode it back to text. Non-Latin characters, emoji and multi-byte scripts are handled correctly — unlike the naive btoa and atob functions built into browsers.

Direction
Result
Type or paste text to encode…

Base64 is encoding, not encryption — anyone can decode it. Everything runs locally; nothing is sent anywhere.

How to use

  1. Choose the direction: encode or decode.
  2. Type or paste your content into the input box.
  3. Turn on “URL-safe” if the result will appear in a URL or filename, or “Add data: prefix” for embedding in CSS or HTML.
  4. Copy or download the result — or send it back to the input with “Use result as input”.

Details

Base64 encodes every 3 bytes into 4 ASCII characters, which is why an encoded string is about a third larger than the original. It exists so that binary data can survive channels designed for text — JSON string values, XML documents, email bodies, data URLs in CSS and HTML, HTTP headers. It is a packaging format, nothing more.

Because Base64 works on bytes and not on characters, text has to be converted to bytes before encoding and back to characters after decoding. This tool uses UTF-8 for that step, which is what virtually every modern system expects, and offers UTF-16LE as an alternative for the few legacy formats that require it. Decoding runs in strict mode by default and points at the exact character that breaks the input, so a string pasted with a missing digit is easy to spot.

FAQ

Why not just use btoa() and atob()?

Because they only handle Latin-1. Calling btoa on a string containing 「中文」 or an emoji throws an InvalidCharacterError, and atob hands back mangled bytes. This tool encodes text to UTF-8 first, then to Base64, and reverses both steps on decode, so any Unicode text round-trips correctly.

What is URL-safe Base64?

Standard Base64 uses + and /, which have special meanings inside URLs and filenames. The URL-safe variant (RFC 4648 §5) substitutes - and _ instead, and often drops the trailing = padding. It decodes to exactly the same bytes, only the alphabet differs.

Is Base64 a form of encryption?

No. Base64 is a transport encoding: it maps bytes to 64 printable characters so binary data can travel through text-only channels such as JSON, email or a URL query string. There is no key and no secrecy — anyone can decode it in a second. Never use it to protect a password, a token or personal data.

What happens when I decode something that is not text?

If the decoded bytes are not valid UTF-8, the tool tells you so in plain language instead of showing replacement characters, and offers a hexadecimal preview of the first two kilobytes so you can inspect what the data actually is — a small image, a compressed stream, or a truncated file.