Base64 Encoder & Decoder - Convert Text, Base64URL, and MIME

Our free Base64 encoder and decoder helps you convert text into Base64 and decode Base64 back into readable text instantly. Base64 is a binary-to-text encoding used across APIs, JWT tokens, email (MIME), and data URIs to safely transmit bytes through text-based systems. Base64 is not encryption — it only changes representation — so never treat Base64 as a security layer.

This tool supports standard Base64 plus the URL-safe Base64URL variant (RFC 4648), where “+” and “/” are replaced with “-” and “_” to prevent URL breakage. It also supports optional padding “=”, since some systems require padding while others omit it. If decoding fails, missing padding or the wrong alphabet (standard vs URL-safe) is usually the reason.

Base64 Conversion

Tip: decoding errors are usually caused by Base64URL vs standard mismatch or missing padding.

How to encode and decode Base64

  1. Paste your input into the text box.
  2. Choose mode: Encode or Decode.
  3. Pick variant: Standard Base64 or Base64URL (URL-safe).
  4. Toggle padding and MIME wrap if your target system requires it.
  5. Copy the output with one click.

Tip: if decoding fails, try Base64URL and/or add missing padding.

Base64 vs Base64URL (URL-safe)

VariantUsesAlphabet differences
Standard Base64General encodingIncludes + and /
Base64URLURLs, JWTUses - and _ instead

Why does Base64 end with “=” or “==”?

Base64 output length must be a multiple of 4 characters. When the input length doesn’t align, Base64 uses “=” padding. Some systems require padding, others omit it — both exist in the wild.

MIME Base64 (76-character line wrapping)

Email tooling often wraps Base64 to 76 characters per line. If you’re working with email headers, attachments, or MIME bodies, enable line wrapping to match expected formatting.

Base64 examples

Text

hello → aGVsbG8=

JSON

{"ok":true} → eyJvayI6dHJ1ZX0=

Data URI (image)

data:image/png;base64,iVBORw0KGgoAAAANSUhEUg...

Best practices

  • Base64 is encoding, not encryption.
  • Use Base64URL for JWT and URL parameters.
  • If decoding fails, check: (1) URL-safe alphabet mismatch, (2) missing “=” padding, (3) whitespace or invalid characters.
  • Base64 increases size by about 33% overhead.

Troubleshooting

ErrorLikely causeFix
Invalid characterWrong alphabet (URL-safe vs standard), or whitespaceToggle Base64URL, remove spaces/newlines
Incorrect paddingMissing “=” paddingEnable padding or add missing “=”
btoa() fails on Unicodebtoa expects Latin1Use UTF-8 safe encoding (this tool does)
MIME output rejectedLine wrapping differencesEnable 76-char wrap for email tooling

Frequently asked questions

What is Base64 used for?

Base64 is used to transmit bytes through text-based systems like JSON APIs, JWT tokens, email (MIME), and data URIs.

Is Base64 encryption?

No. Base64 is encoding (representation), not encryption. Anyone can decode it.

What is Base64URL and why does JWT use it?

Base64URL is the URL-safe Base64 variant (RFC 4648) that replaces “+” and “/” with “-” and “_” so strings don’t break in URLs.

Why does Base64 end with '=' or '=='?

Padding makes Base64 output length a multiple of 4 characters. Some systems require it; others omit it.

How do I fix “incorrect padding” or “invalid character” errors?

Try switching Standard/Base64URL, remove whitespace/newlines, and add missing padding '='.

Why is Base64 output longer than the input?

Base64 adds overhead (~33%) because it encodes 3 bytes into 4 characters.

What is MIME Base64 76-character wrapping?

Email tooling often wraps Base64 lines to 76 characters. This is common for MIME bodies and attachments.

Can I Base64 encode images or files?

Yes, but this tool currently focuses on text. For large binaries, prefer native tooling or dedicated file encoders to avoid memory limits.

Why does btoa()/atob() fail on Unicode?

btoa()/atob() are not UTF-8 safe. This tool uses TextEncoder/TextDecoder so you can encode/decode Unicode reliably.

Does this tool process data locally?

Yes. Encoding/decoding happens in your browser; only “Share result” sends the current input/output to create a share link.

Related tools