Base64 Encoder & Decoder

Convert between text and Base64 in both directions, with correct handling of Unicode and emoji, plus URL-safe mode. Nothing is ever sent anywhere.

Privacy guaranteed: Encoding and decoding happen entirely in your browser. The built-in functions run locally, so your data never touches the network.
The result will appear here

How to use the Base64 encoder

Base64 is a way of encoding binary data using 64 printable characters. Its purpose is not encryption but to let data travel safely through channels that only carry text — a URL parameter, a JSON string, an email body, or a data URI embedded in HTML.

Common use cases

  • API authentication: HTTP Basic Auth puts the username and password in a request header, Base64-encoded
  • Email attachments: the MIME protocol uses Base64 to turn binary attachments into text for transport
  • Inline images: converting a small image into data:image/png;base64,... and writing it straight into CSS or HTML saves a request
  • JWT tokens: the header and payload of a JWT are Base64URL-encoded JSON
  • Avoiding escaping problems: encoding content with special characters before putting it in a config file saves a world of escaping pain

On garbled Chinese text

Many people find that encoding Chinese with JavaScript's btoa() either throws or produces gibberish. The reason is that btoa only accepts characters in the Latin-1 range, and Chinese falls outside it. This tool first converts the text to a UTF-8 byte array with TextEncoder, then Base64-encodes that — so Chinese, Japanese and emoji all encode and decode correctly. Decoding works the same way in reverse: the bytes are recovered first, then restored to text with TextDecoder.

Standard Base64 versus URL-safe Base64

Standard Base64's character set includes + and /, plus a trailing = for padding. All three have special meaning in a URL: + is parsed as a space, / is the path separator, and = is the parameter assignment character. So anything going into a URL or a filename needs the URL-safe variant, where + becomes -, / becomes _, and the trailing = is dropped. JWT uses this variant.

When decoding, this tool converts URL-safe characters back to the standard ones before processing, so both variants decode without you changing anything by hand.

Frequently asked questions

Is Base64 encryption? Can I use it to protect a password?

No, it's just encoding. Anyone can decode it unconditionally, with no key required. Never use Base64 to "encrypt" a password, a key or private data. The base in base64 refers to the 64 characters in the alphabet — it has nothing to do with any "basic version of encryption".

Why does the size grow after encoding?

Base64 uses 4 characters to represent 3 bytes, so the size grows by about 33%. That's the necessary price of trading space for compatibility. If you actually want to reduce size, use gzip rather than Base64.

Can it encode images?

This page handles text. You can convert an image to Base64 first (or use the command line, base64 image.png) and then work with its text form here. Reading files directly in the browser is technically possible, but that belongs to a file tool, which the site may add later.

Do line breaks interfere with decoding?

No. Before decoding, the tool strips all whitespace — spaces, line breaks and tabs — so it works whether or not line breaks are present.

Related tools