Base64 Encoder/Decoder with Binary Safety

Encode or decode Base64 and Base64url strings with binary-safe handling

Ad placeholder (leaderboard)

Base64 turns arbitrary bytes into a text string using 64 printable characters, which lets binary data travel safely through systems that only handle text — email, JSON, data URIs, and JWTs. This tool encodes UTF-8 text or hex bytes into Base64 (or URL-safe Base64url) and decodes either variant back, all in your browser.

How it works

Base64 packs every 3 input bytes (24 bits) into 4 output characters (6 bits each):

  1. Encoding text first converts the string to UTF-8 bytes with TextEncoder, so multi-byte characters such as emoji are preserved.
  2. Each group of 3 bytes maps to 4 characters from the alphabet A-Z a-z 0-9 + /; leftover bytes are padded with =.
  3. Base64url then rewrites + to -, / to _, and strips the = padding so the value is safe inside URLs.
  4. Decoding reverses the process, normalising url-safe characters and restoring padding before rebuilding the bytes, then attempting a strict UTF-8 decode.

If a decode produces bytes that are not valid UTF-8, the tool shows hex rather than mojibake.

Tips and examples

Encoding the text Hi gives SGk=. Encoding the hex bytes 48 69 (which spell “Hi” in ASCII) gives the same SGk=, which is handy for inspecting binary protocol payloads.

When you paste a value shaped like xxxxx.yyyyy.zzzzz, the tool recognises a JWT and reminds you to decode the header and payload segments individually. PEM blocks and data: URIs are flagged too, so you know where the actual Base64 body lives.

Ad placeholder (rectangle)