Base64 to Text Decoder (Live UTF-8 & Data URI Tool)

Decode Base64, Base64URL, and Data URI strings back into readable plain text with full multibyte UTF-8 integrity. Automatically strips data prefixes, parses JWT payloads, handles unpadded strings, and eliminates character corruption (Mojibake).

How Do You Decode Base64 to Text?

To decode Base64 to text, each 4-character block (carrying 6 bits per character, totaling 24 bits) is reconstructed into three 8-bit binary bytes ($24 / 8 = 3$). Those binary bytes are then mapped back to their original ASCII or multibyte UTF-8 characters (e.g., SGVsbG8= decodes to Hello).

16 characters
Valid Base64
12 characters • 12 bytes
Size reduced by ~25%

The Mathematics of Base64: How 4 Characters Become 3 Bytes

Base64 is a binary-to-text encoding scheme defined under RFC 4648. It allows binary octets to be transmitted across channels designed solely for printable ASCII text.

The decoding algorithm reverses 6-bit index grouping back into 8-bit bytes:

  1. Translate 6-Bit Index Values: Each character maps to a number from 0 to 63 based on the Base64 alphabet table ($A=0, \dots, Z=25, a=26, \dots, z=51, 0=52, \dots, 9=61, +=62, /=63$).
  2. Reconstruct 24-Bit Bitstreams: Groups of four 6-bit numbers concatenate to form a 24-bit integer ($4 \times 6 = 24 \text{ bits}$).
  3. Split into Three 8-Bit Bytes: The 24 bits split into three standard bytes ($24 / 8 = 3 \text{ bytes}$):
    [6 bits] [6 bits] [6 bits] [6 bits] → [8-bit Byte 1] [8-bit Byte 2] [8-bit Byte 3]

Understanding Base64 Padding Characters (`=`)

Because Base64 processing operates on 24-bit blocks (3 bytes), inputs whose byte length is not divisible by 3 append trailing padding characters (=) to preserve bit alignment:

Unencoded Byte Length Bit Remainder Base64 Characters Padding Appended Example Encoding
Length % 3 == 0 (e.g., 3 bytes) 24 bits 4 characters None "Man" → "TWFu"
Length % 3 == 2 (e.g., 2 bytes) 16 bits + 2 zero-pad 3 characters = (One pad) "Ma" → "TWE="
Length % 3 == 1 (e.g., 1 byte) 8 bits + 4 zero-pad 2 characters == (Two pads) "M" → "TQ=="

Why Legacy Decoders Corrupt Multibyte Emojis (Mojibake)

Legacy web utilities often decode strings using JavaScript's native window.atob():

// Flawed legacy decoding (Throws URIError or produces Mojibake):
const raw = window.atob("8J+agA=="); // Corrupts rocket emoji into garbled characters

atob() parses binary bytes strictly as single-byte Latin-1 characters (code points 0–255). Because UTF-8 encodes emojis, accents, and international characters across 2 to 4 consecutive bytes, evaluating them as isolated characters corrupts the output (known as Mojibake).

Our decoder streams the decoded binary octets through a native Uint8Array into the Web TextDecoder API, reconstructing multibyte UTF-8 characters cleanly with zero data loss.

Related Developer & Data Utilities:

Frequently Asked Questions

Why does Base64 increase data size by 33%?

Base64 encodes 3 bytes (24 bits) into 4 printable ASCII characters (4 bytes). Because 4 bytes are required to represent 3 bytes of raw data, the total payload expands by a factor of 4/3, resulting in approximately 33% overhead.

What is the difference between Base64 and Base64URL?

Standard Base64 uses + and / characters, which have special meanings in URLs and require percent-encoding (%2B and %2F). Base64URL replaces + with - (hyphen) and / with _ (underscore), making strings safe for web addresses and JWT tokens without escaping.

Can this tool decode Data URIs and JWT tokens?

Yes. The tool automatically detects and strips Data URI headers (e.g., data:text/plain;base64,) and parses three-part JWT strings to decode the middle payload segment directly.

Why does decoding Base64 sometimes show corrupted text (Mojibake)?

Legacy decoders treat each byte as an independent Latin-1 character. When decoding text with emojis, accents, or Asian scripts (which require 2 to 4 UTF-8 bytes per character), the output becomes garbled. This tool uses native Web TextDecoder to maintain full UTF-8 character integrity.

Is Base64 considered encryption?

No. Base64 is an encoding format designed for data transmission, not data security. It uses no secret encryption keys, and anyone with a standard decoder can instantly reconstruct the original plaintext.