Base64 Encode and Decode

Convert text to Base64 and back. Unicode text is handled correctly through UTF-8, and you can switch to the URL-safe alphabet used in tokens and links.

How to use the Base64 Encode and Decode

  1. Pick a mode: encode turns text into Base64, decode turns Base64 back into text.
  2. Type or paste into the input box. The output updates immediately.
  3. For Base64 that goes into a URL or a JWT, tick "URL-safe alphabet" and untick "Keep = padding" if the receiving system expects no padding.
  4. Use "Copy output", or "Use output as input" to flip the result around and check the round trip.

What Base64 is

Base64 represents binary data using 64 printable ASCII characters: A-Z, a-z, 0-9, plus (+) and slash (/). Every 3 bytes become 4 characters, so the encoded text is about one third larger than the original. If the input length is not a multiple of 3, one or two "=" characters pad the end.

Base64 exists so that binary data can travel through systems designed for text, such as email (MIME), JSON fields, data URLs and HTTP headers. It is an encoding, not encryption: anyone can decode it, so it must never be used to protect secrets.

URL-safe Base64 and text encodings

The standard alphabet contains + and /, which have special meaning in URLs. RFC 4648 defines a URL-safe variant that uses - and _ instead and often drops the padding. JSON Web Tokens use this variant.

Base64 works on bytes, so text must first be turned into bytes. This tool uses UTF-8, which is what most modern systems expect. Decoding bytes that are not valid UTF-8, for example an image file, cannot be shown as text, and the tool tells you so instead of printing garbage.

Frequently asked questions

Is Base64 a way to hide or encrypt data?

No. Base64 only changes how data is represented. Anyone can decode it without a key, so do not use it to protect passwords or personal data.

Why does the encoded text end with = signs?

Padding. Base64 works in groups of 3 bytes, and "=" fills the last group when the input length is not a multiple of 3. Many URL-safe uses omit it, and this tool can decode input with or without it.

Why do I get an error when decoding?

The input contains a character outside the Base64 alphabet, has an impossible length, or decodes to bytes that are not valid UTF-8 text. Check for stray quotes or spaces, and for a data URL prefix such as "data:image/png;base64," which is not part of the Base64 itself.

What is the difference between standard and URL-safe Base64?

The standard alphabet uses + and /; the URL-safe one uses - and _. The data is otherwise identical. The decoder here accepts both.

Can I encode a file or an image?

This tool works with text. For files, use a tool that reads the file as bytes. Encoded size will be about 33% larger than the file.