base64

Base64 Encoding: When and Why

Overview

Base64 is a binary-to-text encoding that represents any data using 64 printable ASCII characters (A-Z, a-z, 0-9, +, /). It exists because many systems — email, JSON, URLs, XML — were designed to handle text only, but we often need to transport binary data through them. Encoding adds about 33% overhead (3 bytes of input → 4 bytes of output) in exchange for compatibility. Despite being from 1987, Base64 remains essential for embedding images in CSS/HTML (data URLs), MIME email attachments, JWT tokens, and many web APIs.

How It Works

The encoder takes 3 bytes (24 bits) at a time and splits them into 4 groups of 6 bits each, then maps each 6-bit value (0-63) to one of the 64 characters. If the input length isn't divisible by 3, '=' padding is added. Decoding reverses the process. URL-safe Base64 substitutes '-' for '+' and '_' for '/' so the encoded output can be used in URLs without further encoding. This tool runs entirely in your browser — no data ever transmits to a server.

When to Use This

Encode small images as data URLs to embed directly in HTML or CSS (avoids extra HTTP requests for icons). Decode JWT tokens to inspect their payload (the header and payload are Base64URL-encoded JSON). Convert between binary and text formats when working with APIs that accept only text. Quickly inspect 'mailto:?body=...' or other URLs containing encoded data.

Frequently Asked Questions

Is Base64 encryption?

No — it's encoding, not encryption. Anyone can decode it. Use Base64 only for transport, never for hiding data. If confidentiality matters, encrypt first, then Base64 the ciphertext if needed for text transport.

Why does my encoded string end with '='?

Padding. Base64 outputs in blocks of 4 characters representing 3 input bytes. If input bytes don't divide evenly by 3, '=' fills the last block. One missing byte = '==', two missing = '='.

What's Base64URL?

A variant safe for URLs and filenames — replaces '+' with '-' and '/' with '_', and omits padding '='. Used by JWT tokens and many web APIs. Some tools convert between regular and URL-safe automatically.

Recommended Tools

Hand-picked utilities you might find useful