Base64 Encode & Decode

Convert text to Base64 or decode Base64 back to text — with correct UTF-8 handling so accented characters and emoji round-trip cleanly.

Output will appear here…

How to use it

  1. Choose Encode to turn plain text into Base64, or Decode to turn Base64 back into plain text.
  2. Paste your input into the box — the button label and placeholder update to match the mode.
  3. Click the action button. The result appears below in monospace, ready to copy.
  4. If you're decoding and the input isn't valid Base64, an error box explains what went wrong instead of showing garbage output.

What's actually happening

Base64 takes binary data — raw bytes — and represents it using only 64 printable ASCII characters (A–Z, a–z, 0–9, +, /), with = used for padding at the end. It works by grouping input bytes into chunks of 3 (24 bits) and re-slicing those 24 bits into four 6-bit groups, each mapped to one character in the Base64 alphabet. That's why encoded output is always a multiple of 4 characters long, and why it's roughly 33% larger than the input.

The tricky part is text. JavaScript strings are UTF-16 internally, but Base64 operates on bytes, not characters. This tool first converts your text to UTF-8 bytes using TextEncoder, then maps those bytes through the Base64 alphabet — the same process browsers use internally. Older approaches based on escape()/unescape() or btoa() alone break on anything outside basic Latin characters; this tool avoids that entirely.

Worked example

Plain text
Café ☕ — resumé
Base64 (UTF-8 safe)
Q2Fmw6kg4piVIOKAlCByZXN1bcOp

Notice the accented "é" and the coffee emoji survive the round trip intact — that only works because the encoder operates on UTF-8 bytes rather than treating each character as a single byte.

Reference: Base64 vs. Base64url

CharacterStandard Base64Base64url
Char 62+-
Char 63/_
Padding= requiredOften omitted
Safe in URLs?No — needs escapingYes
Used byEmail (MIME), data URIsJWTs, URL-safe tokens

Frequently asked questions

Is Base64 encryption?

No. Base64 is an encoding, not encryption — it has no secret key and provides no confidentiality. Anyone can decode it instantly, including this tool. It's used to safely represent binary data as text, not to hide information.

Why is the Base64 output longer than my original text?

Base64 represents every 3 bytes of input as 4 output characters, so encoded data is roughly 33% larger than the original. That overhead is the cost of restricting output to a 64-character alphabet that's safe for text-based systems like email and JSON.

Why does my decoded text show garbled characters for emoji or accents?

This usually happens when the original encoding didn't account for UTF-8 multi-byte characters. This tool encodes and decodes using proper UTF-8 byte sequences, so accented letters and emoji round-trip correctly.

What's the difference between Base64 and Base64url?

Standard Base64 uses "+" and "/" and pads with "=". Base64url replaces those with "-" and "_" and often omits padding, because those characters have special meaning in URLs. JWTs use Base64url — see the JWT decoder for a worked example.

Can I Base64-encode a file, not just text?

This tool is built for text input. Base64 itself works on any bytes, including files, but that's a different workflow with different edge cases — intentionally out of scope here to keep this tool fast and predictable.

About this tool

Encoding and decoding use TextEncoder/TextDecoder under the hood for full UTF-8 correctness, not the legacy escape()/unescape() trick that breaks on multi-byte characters. Decoding invalid Base64 (wrong length, invalid characters) is caught and reported clearly rather than silently producing corrupted output.

Related tools