/tools/base64-encoder

Base64 Encoder

Turn text or a small file into a Base64 string. Unicode is handled correctly through UTF-8, and you can switch to the URL-safe alphabet for query strings and JWTs.

Base64 EncoderRuns in your browser

How to use the Base64 Encoder

  1. Type or paste your text, or press Encode a file… to pick a file from your device.
  2. Switch on the URL-safe alphabet if the result will travel in a URL, cookie or JWT.
  3. Press Encode and copy the output.

What Base64 is for

Base64 maps arbitrary bytes onto 64 printable ASCII characters, so binary data can travel through channels that only accept text: email bodies, JSON string fields, XML documents, data URIs and HTTP headers.

The cost is size. Every three bytes become four characters, so encoded data is roughly 33% larger than the original, plus padding. That trade is worth it for a small icon inlined in CSS; it is a poor trade for a 4 MB photograph, which is why this tool caps file input at 5 MB.

Standard vs URL-safe

The standard alphabet ends with + and /, and pads with =. All three are unsafe in URLs: + decodes to a space in query strings, / looks like a path separator, and = separates parameters.

The URL-safe variant (RFC 4648 §5) swaps + for -, / for _, and drops the padding. This is what JSON Web Tokens use. The two forms are not interchangeable — decode with the same alphabet you encoded with.

Base64 is not encryption

Anyone can decode Base64 instantly, without a key. It provides zero confidentiality. If you are considering it to hide an API key or a password, it will not help — the value is fully recoverable by anyone who sees it. Use encryption for secrecy and hashing for verification.

Frequently asked questions

Does it handle emoji and non-Latin scripts?

Yes. The text is converted to UTF-8 bytes before encoding, so accented characters, CJK text and emoji all survive the round trip. The older btoa function alone would throw an error on these.

Why does my output end in one or two equals signs?

Base64 works in three-byte groups. When the input length is not a multiple of three, padding marks how many bytes were in the final partial group. The URL-safe option removes it.

What is line wrapping for?

MIME email requires lines no longer than 76 characters. If you are pasting into an email header or an old system, switch it on. For JSON or JavaScript, leave it off.

Are my files uploaded?

No. Files are read with the browser FileReader API and encoded locally. Nothing is sent over the network.

Related tools