Base64 is one of the most common encodings in web development, yet it's often misunderstood. Here's the concise guide.
What is Base64?
Base64 encodes arbitrary binary data as printable ASCII text using a 64-character alphabet (A–Z, a–z, 0–9, +, /). Every 3 bytes of input produce 4 characters of output — a ~33% size overhead.
Why does it exist?
Many protocols (SMTP, HTTP headers, HTML attributes) were designed for text and can't safely carry raw binary. Base64 sidesteps this by representing binary as plain text.
Common uses
- Data URIs — embed images directly in HTML/CSS:
src="data:image/png;base64,iVBOR..." - JWT tokens — header and payload are Base64URL-encoded JSON
- HTTP Basic Auth — credentials are Base64-encoded before the request
- Email attachments — MIME multipart encodes binary attachments as Base64
Base64 vs Base64URL
Base64URL replaces + with - and / with _, and omits padding, making the output safe for URLs and filenames without percent-encoding.
It is NOT encryption
Base64 is encoding, not encryption. Anyone can decode it instantly. Never use it to obscure sensitive data.
Encode and decode Base64 instantly with ByteForge's Base64 tools.