Developer & Tech

Base64 Encoder & Decoder

What this does

Convert text to Base64 and back with full UTF-8 support; multilingual characters and emoji survive every round trip.

Enter your details

Runs in your browser

Calculator inputs

Using the base64 encoder & decoder

  1. 01

    Paste your content

    Any text in any language; encoding handles the full Unicode range.

  2. 02

    Pick the direction

    Encode turns text into Base64; decode expects valid Base64 and returns text.

  3. 03

    Copy the result

    Encoded output includes standard “=” padding accepted everywhere.

What Base64 is actually for

Base64 converts arbitrary bytes into printable ASCII safe for channels designed around text: email attachments, JSON string fields, data URIs, HTTP basic auth headers. It costs about 33% extra size; it is an encoding, never encryption.

The Unicode trap

Naïve btoa() usage throws on characters above U+007F because it treats each char as a byte. Correct handling encodes UTF-8 bytes first; which is exactly what this tool does, so 世界 and emoji survive intact both directions.

Padding rules worth knowing

  • Length divisible by 3 → no padding
  • One byte left over → “==”
  • Two bytes left over → “=”
  • Stray “=” anywhere else means corruption

The math behind this calculator

Base64: groups of 3 bytes → 4 characters; padding = pads the final partial group

Text is first converted to UTF-8 bytes, then each group of three bytes (24 bits) is split into four six-bit values mapped onto the standard A–Z, a–z, 0–9, +, / alphabet. A leftover group of one or two bytes is padded with one or two “=” signs.

Decoding reverses the mapping after validating the alphabet, length multiple of four and correct padding placement, so corrupt input fails loudly instead of silently producing garbage bytes.

Assumptions & limitations

  • Standard alphabet with + and / (not the URL-safe -_ variant).
  • Whitespace inside Base64 is ignored when decoding.
  • Decoded bytes are interpreted strictly as UTF-8.

Worked example

“Hello, 世界!” contains multibyte UTF-8 characters; its encoding is the classic SGVsbG8sIOS4lueVjCE=; proof the pipeline is Unicode-safe.

Frequently asked questions

Is Base64 encryption?
No; it is a reversible encoding with no key. Anyone can decode it instantly; use it for transport compatibility, never secrecy.
Why does encoded output end with = sometimes?
Padding completes the final incomplete 3-byte group so total output length is always a multiple of four characters.
Can I decode URL-safe Base64 (- and _)?
Not directly here; replace dashes with + and underscores with / first, then add missing padding.
Why did decoding fail?
Most often a stray character outside the alphabet, wrong padding, or a length that is not a multiple of four. The error names the specific problem.

Related calculators