Base64 decode and encode

Paste Base64 to read it, or type text to encode it. UTF-8 safe, URL-safe variant, files and data URIs — all processed on your device.

How Base64 works — watch the bits

Base64 in practice

  • HTTP Basic auth sends user:password Base64-encoded in the Authorization header — readable by anyone, so only over HTTPS.
  • JWTs are three base64url strings joined by dots. Decode one with the JWT decoder.
  • Data URIs embed small images in CSS or HTML: data:image/png;base64,iVBOR….
  • Email attachments (MIME) are Base64 wrapped at 76 characters per line — this decoder ignores the line breaks.

On the command line

echo -n 'hello' | base64        # aGVsbG8=
echo 'aGVsbG8=' | base64 --decode   # hello   (macOS: base64 -D)

# JavaScript (UTF-8 safe)
btoa(String.fromCharCode(...new TextEncoder().encode('✓')))
new TextDecoder().decode(Uint8Array.from(atob(b64), c => c.charCodeAt(0)))

# Python
import base64; base64.b64encode('✓'.encode()).decode()

Plain btoa('✓') throws in browsers because it only accepts Latin-1; encode to UTF-8 bytes first as above.

Questions

Is Base64 encryption?

No. Base64 is an encoding — anyone can decode it instantly, as this page shows. It exists to carry binary data through channels that only handle text (email, JSON, URLs, HTML). Never use it to hide secrets.

What is URL-safe Base64?

A variant (RFC 4648 §5, "base64url") that uses - and _ instead of + and / and usually drops the = padding, so the result can sit in a URL or filename without escaping. JWTs use it.

Why does decoding give garbled characters?

Either the data is binary (an image, a zip) rather than text, or it was encoded from text in a different character set. This tool encodes and decodes text as UTF-8, which handles emoji and every language.

Why is Base64 about 33% bigger?

Every 3 bytes (24 bits) become 4 characters of 6 bits each, so output is 4/3 the size of the input, plus up to two = padding characters.

Does it work with files and images?

Yes. Choose a file to get its Base64, optionally as a data: URI you can paste into CSS or an <img> tag. Paste Base64 in decode mode and use Download to save the original bytes. Files never leave your browser.