What Is Base64?
Base64 is an encoding scheme that converts binary data into ASCII text using 64 printable characters (A–Z, a–z, 0–9, +, /). It allows binary content to be safely embedded in text-based formats like JSON, XML, or HTML.
How It Works
- Every 3 bytes of binary input → 4 Base64 characters
- Output size is always ~33% larger than the input
- Padding characters (
=) align the output to multiples of 4 - URL-safe variant replaces
+with-and/with_
Common Uses
- Embedding images directly in HTML/CSS as
data:URIs - Transmitting binary data in JSON API payloads
- Encoding email attachments (MIME standard)
- Storing small binary blobs in databases
- Basic token encoding in HTTP Basic Auth headers
Is Base64 encryption?
No — Base64 is encoding, not encryption. Anyone with the encoded string can decode it instantly with no key. Never use Base64 to protect sensitive data. For security, use actual encryption (AES, RSA) and hashing (SHA-256) instead.
What is URL-safe Base64?
Standard Base64 uses + and / which have special meanings in URLs. URL-safe Base64 replaces them with - and _, making the output safe to include in query strings and path segments without percent-encoding.
Why does Base64 output end with == or =?
Base64 encodes 3 bytes at a time. If the input length isn't a multiple of 3, one or two = padding characters are added to fill the final group. Two = means 1 remaining byte; one = means 2 remaining bytes.