Base64 Encoder & Decoder

Convert text and files to Base64 and back. Handles Unicode correctly, supports URL-safe base64url, and tells you exactly why invalid input fails.

Runs in your browserNo sign-upNothing uploaded

Base64 output

How to use the Base64 Encode / Decode

  1. Choose Encode or Decode.
  2. Type or paste your input. The result updates as you type.
  3. For URLs, JWTs and filenames, tick URL-safe to use - and _, and optionally drop the = padding.
  4. To embed an image or font, click Encode file and keep Output as data URI checked.
  5. Copy the result, or use Swap to feed it back in the other direction.

How Base64 works

Base64 represents binary data using 64 printable ASCII characters: A-Z, a-z, 0-9, + and /. Every 3 bytes of input become 4 characters, so encoded data is about 33% larger. When the input length is not a multiple of 3, one or two = signs pad the output. Base64 is an encoding, not encryption: anyone can decode it.

Standard Base64 vs. base64url

The + and / characters have special meaning in URLs and file paths. The URL-safe alphabet from RFC 4648 §5 replaces them with - and _ and usually omits padding. JWTs, many OAuth parameters and some cloud APIs use base64url. The decoder here accepts both alphabets automatically.

Unicode and the btoa() pitfall

In browsers, btoa("café") works but btoa("日本") throws, because btoa only accepts Latin-1. The correct approach is to encode the text to UTF-8 bytes first, which this tool does. In JavaScript: btoa(String.fromCharCode(...new TextEncoder().encode(text))), or Buffer.from(text).toString('base64') in Node.js.

Common uses

  • Data URIs for small images and fonts in CSS or HTML
  • HTTP Basic authentication headers (user:password encoded)
  • Binary attachments in JSON payloads and email (MIME)
  • Kubernetes Secrets, which store values as Base64

Frequently asked questions

Is Base64 encryption?
No. Base64 is a reversible encoding with no key. Anyone can decode it, so never use it to hide passwords or secrets.
Why does my Base64 fail to decode?
Common causes are characters outside the alphabet (often a stray quote or line break from copying), a truncated string, or mixing in text that is not Base64. The error message shows the position of the first problem.
The decoded output looks like garbage. Why?
The data is probably binary, for example an image, a compressed file or encrypted bytes, rather than text. The tool detects this, shows a hex dump, and lets you download the raw bytes.
Do I need the = padding?
Many decoders, including this one, work without it because the length tells them how many bytes are missing. Some strict decoders require it. JWTs and most base64url uses omit padding.
Are my files uploaded?
No. Files are read and encoded locally with the browser’s File API. Nothing is sent to a server.

Related tools