← All tools Developer

Base64 Encoder / Decoder

Encode text to Base64 or decode Base64 back to text in real time. Supports full Unicode. Everything runs locally — your data never leaves the browser.

0 chars

What Is Base64 Encoding Used For?

Base64 is one of the most widely used encoding schemes in web development. It converts binary data into a string of 64 safe ASCII characters, allowing you to transmit binary content through text-only channels like email, JSON payloads, and URL parameters.

Every developer encounters Base64 regularly — from embedding images in CSS to decoding JWT tokens to reading email attachments. Understanding how it works is a fundamental skill.

Common Use Cases

Data URIs

Embed small images, fonts, or SVGs directly in HTML or CSS using data:image/png;base64,… to eliminate HTTP requests.

Email Attachments (MIME)

Email protocols like SMTP are text-based. Binary attachments (images, PDFs) are Base64-encoded for safe transmission within the email body.

HTTP Basic Authentication

The Authorization header uses Base64 to encode the username:password string. Note: this is not encryption — always use HTTPS alongside it.

JSON Web Tokens (JWT)

JWT tokens are three Base64URL-encoded segments separated by dots. Decoding the payload segment reveals the token claims (user ID, expiry, roles).

Binary Data in JSON/XML

When an API needs to include binary data (like a file upload) in a JSON payload, Base64 encoding makes the binary content safe to include as a string value.

Is Base64 Secure? (No.)

This is one of the most common misconceptions in web development. Base64 is an encoding scheme, not encryption. It is fully reversible by anyone with no key required. You should never use Base64 to hide or protect sensitive data like passwords, tokens, or personal information.

⚠️ Security reminder

For actual data protection, use encryption algorithms like AES-256-GCM for symmetric encryption or RSA/ECDSA for asymmetric encryption. Base64 is only for encoding, never for security.

Using Base64 for Data URIs

Data URIs let you embed file content directly in HTML or CSS, eliminating the need for a separate HTTP request. This is particularly useful for small assets like icons, logos, or simple SVGs that would otherwise require additional network round-trips.

data:[mediatype];base64,[encoded-data]

Keep in mind that Base64 increases the data size by 33%, so this technique is best for files under 10 KB. Larger files are more efficiently served as separate resources that can be cached by the browser.

Frequently Asked Questions

What is Base64 encoding?

Base64 is a binary-to-text encoding scheme that converts binary data into a string of ASCII characters. It uses a set of 64 characters (A–Z, a–z, 0–9, +, /) to represent data, making it safe to transmit binary content through text-only channels.

Is Base64 encoding the same as encryption?

No. Base64 is an encoding scheme, not encryption. It provides no security or confidentiality. Anyone can decode a Base64 string back to its original form without a key. For protection, use proper encryption like AES or RSA.

What are Data URIs and how do they use Base64?

A Data URI embeds file content directly in HTML or CSS using Base64 encoding. For example, you can inline a small PNG image to eliminate an HTTP request. The trade-off is a 33% increase in the encoded size.

Why does Base64 increase file size?

Base64 encodes 3 bytes of binary data into 4 ASCII characters, resulting in a 33% size increase. This overhead is the trade-off for being able to represent binary data as safe ASCII text.

When should I use Base64 encoding?

Use Base64 when embedding binary data in text formats like HTML, CSS, JSON, or XML. Also for email attachments (MIME), HTTP Basic Auth headers, and inlining small assets to reduce HTTP requests. Avoid it for large files due to the 33% size overhead.