Base64 Encoder and decoder

☀️
🌙

Bytes (UTF-8): 0

Length: 0

How input text is converted to bytes

Insert line breaks every N chars

Use - and _ instead of + and /

Notes about charsets
UTF-8 is recommended. Latin-1 maps code points 0–255 directly. UTF-16LE here is a naive 2-byte per char encoding (surrogate pairs become 4 bytes). For full multi-charset support, use a dedicated encoding library.
How to use — Base64 Encoder

Quick Start

  1. Paste your text into Input Text.
  2. Select Character Set (UTF-8 is recommended).
  3. (Optional) Set Newline Wrapping for PEM/MIME use.
  4. (Optional) Toggle URL Safe to use - and _.
  5. (Optional) Strip padding (=) only if the receiver allows it.
  6. Copy the result from Base64 Output.

Options Explained

Character Set

Controls how your text becomes bytes before encoding.

  • UTF-8: universal & lossless; supports all languages and emoji.
  • Latin-1: single-byte (0–255); no emoji/Asian scripts.
  • UTF-16: 2-byte code units; use only if required by the receiver.

Newline Wrapping

  • None: best for JSON/APIs.
  • 64 / 76 columns: PEM/MIME/email. Pick CRLF (Windows) or LF (Unix).

URL Safe

Replaces +- and /_ for URLs/JWTs.

Strip padding (=)

Removes trailing =. Enable only if the receiver supports unpadded Base64.

What Happens Under the Hood

  1. Text → bytes via chosen charset.
  2. Group into 3 bytes (24 bits).
  3. Split to four 6-bit values; map to Base64 index table.
  4. Pad with = if 1 or 2 bytes remain.
Raw bytes (24 bits):     01001001 01101110 01100110
Split into 6-bit groups: 010010 010110 110011 100110
Base64 characters:       S      W      z      m
      

Output Size

EncodedSize = 4 × ceil(rawSize / 3)

Troubleshooting

  • Garbled characters on decode: charset mismatch—use UTF-8 on both sides.
  • Rejected in URLs: enable URL Safe; consider stripping padding.
  • Email wraps lines: wrap at 76 with CRLF.
  • Output looks bigger: Base64 adds ~33% by design.
Security note
Base64 is reversible; use encryption for confidentiality.