Base64 Encode / Decode
Encode text to Base64 or decode Base64 to text
What is Base64?
Base64 is a binary-to-text encoding scheme that represents binary data in an ASCII string format. It is commonly used when binary data needs to be transmitted over media designed to handle textual data. Base64 encoding transforms data into a sequence of 64 characters (A-Z, a-z, 0-9, +, /) plus the = padding character.
When to Use Base64 Encoding
- Email attachments (MIME) — Base64 is used to encode binary attachments in email messages so they can travel through SMTP servers that handle only text.
- Data URIs in web pages — Embed small images, fonts, or other resources directly in HTML or CSS using
data:URIs with Base64 encoding, reducing HTTP requests. - API authentication — HTTP Basic Authentication uses Base64 to encode username:password pairs (though this is not secure encryption; use HTTPS).
- JSON Web Tokens (JWT) — JWT header and payload sections are Base64-encoded JSON objects.
- Storing binary data in databases — Encode binary files as Base64 strings for storage in text-based database columns.
Important Notes
- Base64 is an encoding, not encryption. It provides no security — anyone can decode Base64 data easily.
- Base64 encoding increases data size by approximately 33% due to the overhead of representing binary data as text.
- Not all Base64 strings are valid — they must follow the correct character set and padding rules.
- URL-safe Base64 variants replace + with - and / with _ to work in URLs without escaping.