Base64 Encoder and Decoder

Encode text or files to Base64, or decode Base64 back to text or the original file. This Base64 encoder and decoder supports UTF-8 and the URL-safe alphabet.

Updated
Runs in your browser. Your data is not uploaded.
Direction

How to use the Base64 Encoder and Decoder

  1. Pick the Text tab to paste text, or the File tab to choose a file up to 5 MB.
  2. Choose Encode or Decode. Tick URL-safe for the - and _ alphabet, or Output as data URI for files.
  3. Read the result, then press Copy or Download. Decoding in the File tab downloads the original file.

How it works

Base64 (RFC 4648) splits data into groups of 3 bytes, which is 24 bits, and writes each group as 4 characters of 6 bits each. The 64 characters are A-Z, a-z, 0-9, +, and /. When the last group is short, = pads the output.

  • Text is converted to UTF-8 bytes before encoding, so any language works.
  • URL-safe Base64 uses - and _ instead of + and /, and leaves out the padding.
  • Decoding accepts both alphabets, missing padding, and spaces or line breaks in the input.

Examples

  • Hello, World! = SGVsbG8sIFdvcmxkIQ==.
  • Café = Q2Fmw6k=. In URL-safe form: Q2Fmw6k.

Where Base64 is used

  • Data URIs: small images and fonts embedded directly in HTML or CSS
  • Email attachments: MIME encodes attached files as Base64
  • JSON and XML: binary data such as a file or a key sent inside a text format
  • HTTP Basic authentication: the user name and password in the header are Base64-encoded, which is why Basic auth must only be used over HTTPS
  • Tokens: JSON Web Tokens use URL-safe Base64 for their three parts

Limitations

  • Files are limited to 5 MB.
  • Characters outside the Base64 alphabet, or an impossible length, give an error.
  • If decoded bytes aren't valid UTF-8 text, the Text tab says "This looks like binary data" and offers a download instead.
  • Base64 is an encoding, not encryption. Anyone can decode it.

Frequently asked questions

Is Base64 encryption?

No. Base64 is an encoding that anyone can reverse. Don't use it to hide passwords or secrets.

Why is the Base64 output larger than the input?

Base64 turns every 3 bytes into 4 characters, so the output is about 33% larger.

What is URL-safe Base64?

A variant that replaces + and / with - and _ and drops the = padding, so the result can go in URLs and filenames.

Are my files uploaded?

No. Encoding and decoding happen in your browser.

Often used together with the Base64 Encoder / Decoder.