Base64 Encoding: Complete Guide
Last updated: April 2026 · 4 min read
Base64 is an encoding scheme that converts binary data into a safe ASCII string. It's one of the most common encodings in web development, used everywhere from JWT tokens to email attachments to data URLs.
Why is Base64 Used?
Binary data (images, files, binary protocols) can't always be safely transmitted as text. Base64 converts binary bytes into a set of 64 printable ASCII characters — making it safe for JSON payloads, HTTP headers, HTML data attributes, and email bodies.
Common Use Cases
- JWT tokens — the header and payload are Base64url encoded
- Data URLs — embed images directly in HTML:
src="data:image/png;base64,..." - API authentication — HTTP Basic Auth sends credentials as Base64
- Email attachments — MIME encodes attachments in Base64
- CSS background images — inline small icons for zero HTTP requests
Base64 vs Base64url
Standard Base64 uses + and /, which are unsafe in URLs. Base64url replaces them with - and _. JWT tokens use Base64url.
How to Decode a JWT Token
A JWT has three parts separated by .: header.payload.signature. The first two parts are Base64url encoded JSON. To inspect a JWT:
- Split by
.and take the second part (payload) - Decode it as Base64
- Parse the resulting JSON to see claims (user ID, expiry, etc.)
Try Our Free Base64 Tool
Our Base64 encoder/decoder handles text and supports both standard Base64 and URL-safe Base64. All processing happens locally in your browser.
Encode / Decode Now →