Base64 encode and decode

Type or paste text to encode it as Base64, or paste Base64 to decode it. Unicode text and emoji round-trip correctly, and URL-safe Base64 works both ways.

runs in your browser · nothing uploaded

loading tool…

How to use it

  1. Choose Encode or Decode.
  2. Paste your input. The output updates as you type.
  3. Tick "URL-safe" to use - and _ instead of + and / and drop the = padding (RFC 4648 section 5).
  4. Copy the output.

What Base64 is for

Base64 (RFC 4648) turns any bytes into 64 printable characters, so binary data can travel through systems that only expect text: email attachments, data: URLs, JSON fields, HTTP Basic auth headers and JWTs.

It is an encoding, not encryption. Anyone can decode it, so never use it to hide a secret. Encoded output is about a third larger than the input, because every 3 bytes become 4 characters.

Why btoa() breaks on emoji

The browser's built-in btoa() only accepts characters in the Latin-1 range, so btoa("✓") throws an error. This tool first turns your text into UTF-8 bytes with TextEncoder and then encodes those bytes, which is what other languages do by default. Decoding reverses it with TextDecoder.

Standard vs URL-safe

Standard Base64 uses + and /, which have meaning in URLs and file names. The URL-safe alphabet swaps them for - and _. JWTs use URL-safe Base64 without padding. When decoding, this tool accepts either alphabet and missing padding.

Questions

Is what I paste sent to a server?

No. The tool runs entirely in your browser with JavaScript. Nothing you type or paste is uploaded, logged or stored by us, so it is safe to use with real data.

Why does decoding give strange characters?

The Base64 probably holds binary data, such as an image or a compressed file, rather than text. Text decoding shows such bytes as replacement characters. Decoding is still correct; the content just is not text.

Can I encode a file?

This page encodes text. To turn an image into a data: URL, you can also use your browser's developer tools or a command such as base64 -w0 file.png on Linux.

Is Base64 secure?

No. It hides nothing. Anyone can decode it in one step. Use real encryption for secrets.