Base64 Encoder and decoder

☀️
🌙

Paste or type Base64 text to decode

Length: 0

How decoded bytes are interpreted

Normalize newlines before decoding

Charset notes
UTF-8 is recommended. Latin-1 maps bytes 0–255 directly. UTF-16LE here assumes 2 bytes per character; surrogate pairs decode to two UTF-16 code units.
How to use — Base64 Decoder

Quick Start

  1. Paste your Base64 string into Base64 Input.
  2. Choose Character Set to interpret the decoded bytes (UTF-8 is recommended).
  3. (Optional) Set Newline Handling to normalize \r\n / \n before decoding.
  4. Read the plain text in Decoded Output. Use Copy Output to copy and Clear to reset.

Options Explained

Character Set

Controls how the raw bytes (after Base64 decode) are turned into text. If the string was originally encoded from UTF-8 text, choose UTF-8 here to recover it exactly.

  • UTF-8: universal & lossless for modern text and emoji.
  • Latin-1: one byte per char (0–255); for legacy Western data.
  • UTF-16LE/BE: two-byte code units; only use if the source was UTF-16.

Newline Handling

Some inputs contain wrapped lines (PEM/MIME) or mixed line endings. Normalizing before decode avoids “invalid character” errors.

  • Windows (CRLF): normalize to \r\n.
  • Unix (LF): normalize to \n.
  • None: leave input untouched (best for API/JSON values).

What Happens Under the Hood

  1. Base64 input → four 6-bit values per 4 chars (map via Base64 index table).
  2. Every 4 values (24 bits) are re-packed into 3 bytes.
  3. Padding = indicates the final block had 1 or 2 missing bytes.
  4. Bytes → text using the selected Character Set.
SWVsbG8sIEJhc2U2NA==      →  Base64 groups: 0..63 values
Groups (24 bits total)    →  Repack to bytes
Bytes + UTF-8 decode      →  "Hello, Base64"
      

Examples

Simple:

"SGVsbG8="  →  Hello
      

With URL-safe input: replace -+ and _/ before decoding; add padding if needed.

"SGVsbG8" (unpadded) → add "=" to make length multiple of 4 → "SGVsbG8="
      

Troubleshooting

  • “Invalid character” / “Incorrect padding”: remove spaces/line breaks or normalize; ensure length is a multiple of 4 (pad with =).
  • Garbled output: wrong charset—try UTF-8; match the charset used at encode time.
  • URL/JWT value fails: convert URL-safe symbols back to +// and restore padding.
  • Blank result with emojis: decode bytes with UTF-8, not Latin-1.
Security note
Decoding Base64 reveals the original bytes exactly—there’s no protection. Treat decoded content as plain data.