Skip to content
← Back

Base64 Encoder/Decoder - Online Base64 Encode/Decode

Text
Runs locally · Not uploaded

Online Base64 encoder and decoder with UTF-8 by default for Chinese and emoji, plus GBK / Latin-1 charset switching. All processing runs locally in your browser. No data sent to servers.

Was this result helpful?

For local tools, open DevTools → Network and search your input — it should not appear in requests.

Next steps

Usage Guide

Base64 encodes arbitrary bytes into 64 printable characters — the most ubiquitous encoding in data transport. This tool defaults to UTF-8 for Chinese and emoji, and lets you switch to GBK or Latin-1; it accepts standard and URL-safe variants (including missing padding). All work runs locally in your browser; pasted content never reaches any server.

1. The real reason Chinese text decodes into garbage

Base64 encodes bytes, not characters. The same 「你好」 is 5L2g5aW9 under UTF-8 but xOO6ww== under GBK — entirely different strings. Decode a GBK payload as UTF-8 and you get runs of �; decode a UTF-8 payload as Latin-1 and you get ä½ å¥½. Troubleshooting order: confirm the source charset, then switch Charset in the tool. The UI hints on � / ä¸ signatures instead of silently answering wrong.

2. Choosing a charset

  • New work and modern APIs: keep UTF-8 (default).
  • Legacy Windows Chinese stacks or some banking/gov APIs: pick GBK before encode or decode.
  • When hunting “UTF-8 bytes read as Latin-1”: decode as Latin-1 for comparison, then verify with UTF-8.
  • File drops encode raw bytes and ignore the text charset control; the control applies to the text box path.

3. URL-safe variants and padding rules

  • The standard alphabet includes + and /, both of which get percent-escaped inside URLs — hence the URL-safe variant: + becomes -, / becomes _.
  • The = padding is equally URL-hostile, and many implementations (JWT included) strip it; decoders must re-pad the length to a multiple of 4 before decoding.
  • This tool auto-pads missing input; to judge whether a string is Base64 at all, check that its alphabet stays within A-Za-z0-9+/= (or -_=).

4. Base64 is not encryption

Base64 is an encoding, not encryption: anyone can reverse it instantly, so its confidentiality is exactly zero — a letter in a transparent envelope. It exists for one purpose: letting binary data pass safely through ASCII-only channels (email bodies, URL parameters, JSON strings, data URIs). For actual secrecy use real encryption such as AES-GCM (see the AES tool on this site); Base64 solves whether data can travel, not who can read it.

5. The exact size inflation rule

Every 3 bytes become 4 characters, so standard Base64 output is always 4/3 of the input (about +33.3%), padded with = when short of a full triple; the exact formula is 4 × ceil(n/3). Concrete impact: a 1 KB image becomes roughly 1366 characters; inlining images into CSS or JSON stacks this inflation on top of reduced gzip effectiveness (Base64 text compresses notably worse) — data URIs are for small icons of a few KB, not large images.

6. Identifying what you just decoded

  1. Starts with data: → it is a data URI; paste it into an address bar or img tag to render.
  2. Starts with PK (hex 50 4B) → a ZIP-family archive (docx/xlsx/jar all qualify); save with the right extension and open.
  3. Starts with %PDF → a PDF document; save as .pdf.
  4. Readable JSON/XML → likely a JWT payload, config fragment or API response; continue with a JSON formatter.

7. MIME line wraps, whitespace, and almost-Base64 input

Email and some legacy gateways insert a line break every 76 characters per MIME rules; pasting that into a strict decoder fails on whitespace. This tool tolerates common whitespace during normalize and restores missing =. If it still fails, check in order: non-alphabet glyphs (smart quotes), whether the string is actually Base32/hex, or whether you pasted a whole JWT (three segments) into a single Base64 field — use the JWT decoder for that. File drops follow the raw-byte path; the charset control applies only to the text box — do not mix the two when diagnosing.

8. How this page relates to Base64URL, JWT and data URIs

  • Query strings and JWT segments use Base64URL (- _, often unpadded); the URL-safe toggle covers that alphabet.
  • A full JWT (two dots) belongs in the JWT decoder, which splits three segments and explains claims.
  • For image/audio inlining prefer the Base64-to-image or data-URI tools; this page focuses on text round-trips and charset triage.

FAQ

Base64 encodes bytes, not characters: 「你好」 is 5L2g5aW9 under UTF-8 but xOO6ww== under GBK, entirely different outputs. Decoding with the wrong charset yields runs of � or ä½ å¥½-style garbage. First confirm the source system's charset (legacy Windows Chinese systems and some bank or government interfaces commonly use GBK), then switch the Charset option and decode again — the UI hints at a charset change when it spots these symptoms. Dropped-in files are processed as raw bytes; the charset option applies only to the text box.

Yes. The URL-safe alphabet swaps + for - and / for _, and many implementations (JWT included) strip the padding = entirely. The tool restores missing padding to a multiple of 4 before decoding, and tolerates common whitespace such as the line breaks mail systems insert every 76 characters. For a complete JWT (two dots, three segments), use the JWT decoder instead — it splits the segments and explains the claims.

No. Base64 is encoding, not encryption: anyone who obtains it can restore the original instantly, so its confidentiality is zero — a letter in a transparent envelope. It exists so binary data can cross text-only channels (URL parameters, JSON strings, email bodies, data URIs). For confidentiality use real encryption such as AES-GCM; the AES tool on this site pairs well with it.

Every 3 bytes become 4 characters, so standard Base64 output is always 4/3 of the input (about +33.3%); the exact formula is 4 × ceil(n/3), so a 1 KB image lands around 1366 characters. Inlining images into CSS or JSON also drags down gzip compression — favor small icons of a few KB for data URIs and think twice before inlining large images.

Check the leading bytes: data: means a data URI you can use directly as an image address; PK (hex 50 4B) marks the ZIP family (docx, xlsx, jar are all ZIP-based) — save it and rename the extension to open it; %PDF is a PDF document; readable JSON or XML usually means a JWT payload, config fragment, or API response, ready for the JSON formatter.

No. Encoding and decoding execute entirely inside the browser, pasted content is never uploaded, and the whole operation makes no network requests.

Related Tools

Related Articles