Switch tool

Base64 Encode / Decode

Text, files and images ↔ Base64 (standard / URL-safe / MIME).

Mode
Variant
Plain input
0 chars · 0 bytes
Base64 output
0 chars · 0 bytes

How to use

Purpose

Online Base64 encoder and decoder for text, images, and files. Text mode encodes any string (including Chinese, Emoji, special characters) to Base64-safe ASCII; decoded back, default UTF-8 encoding. Image mode converts local PNG/JPG/WebP to data URLs for embedding in HTML/CSS. File mode converts small binaries to Base64 for JSON APIs or email attachments. All processing happens locally in the browser. Also supports URL-safe Base64 (for JWT/URLs), padding control, and MIME line-wrap variants.

Steps

  1. Pick mode: text (default), image, or file
  2. Text mode: paste source on the left, get Base64 on the right; reverse paste auto-decodes
  3. Character set: UTF-8 (default, safe for Chinese/Emoji), ASCII, GBK
  4. URL-safe option: replace +/= with -_ and drop padding (for URL parameters and JWT)
  5. MIME mode: wrap every 76 columns (for email multipart encoding)
  6. Image mode: drop a file to get data:image/png;base64,... full data URL
  7. File mode: drop any file (≤5MB recommended) to get Base64; download as .txt
  8. Decoding auto-detects content type — text shows directly, image/file offers download

FAQ

How much larger is Base64 vs the original?
About 33% larger (4/3 ratio). Every 3 bytes encode to 4 Base64 characters. 1KB source → ~1.33KB Base64. This is why large files should not be transported as Base64 — wasted bandwidth and JSON parsing overhead.
Chinese strings come out garbled after decode?
Usually a charset mismatch. This tool defaults to UTF-8. If the source was GBK-encoded (legacy Windows or some PHP backends), convert GBK to UTF-8 first or switch the charset. Base64 only encodes bytes — it does not know the character encoding.
What is the difference between URL-safe Base64 and standard Base64?
Standard Base64 uses + / =. But + means space in URLs, / is a path separator, and = cannot appear in query parameters. URL-safe replaces + with -, / with _, and usually drops =. Used in JWT, URL params, filenames.
Why does my JWT token fail to decode as Base64?
JWT uses URL-safe Base64 without padding. A standard Base64 decoder errors on - _ or missing =. Toggle "URL-safe" here, or use jwt-decoder for one-click parsing.
Does embedding an image as Base64 in HTML load faster?
Small icons (<5KB) embedded as data URLs save an HTTP request — slightly faster. Large images bloat HTML and cannot be cached independently. Rule of thumb: <2KB logos/decorative icons inline, others use <img src>.

Use cases

  • Embedding images in CSS/HTML: small logos as data URLs avoid extra requests
  • Debugging JWTs: decode header/payload segments using URL-safe Base64
  • Sending images via APIs: when the backend only accepts JSON, encode the image and send in a field
  • Multilingual email subjects: RFC 2047 mandates non-ASCII subjects use Base64 + UTF-8
  • Generating test data: convert binary blobs to Base64 strings for Postman or unit tests

Use cases

Embedding icons in CSS, JWT debugging, binary-over-JSON APIs, multilingual email subjects, test data generation. Frontend, backend, QA, security engineers. UTF-8/GBK charset switching, URL-safe variant, and image/file modes are the differentiators.