0 bytes

About Base64 Encode / Decode

Base64 is a binary-to-text encoding scheme that represents binary data using 64 printable ASCII characters. It is widely used in web development for embedding images directly in HTML or CSS, transmitting binary data in JSON payloads, storing credentials in HTTP Basic Auth headers, and encoding email attachments.

URL-safe variant

Standard Base64 uses the characters + and / which are special characters in URLs. URL-safe Base64 substitutes - for + and _ for /, making encoded strings safe to include in query parameters without encoding.

Note on security

Base64 is encoding, not encryption. It provides no security — any encoded string can be trivially decoded. Never use it to protect passwords or sensitive data.

Base64 variants: standard, URL-safe, and MIME

Standard Base64 uses A-Z, a-z, 0-9, + and / with = padding. URL-safe Base64 replaces + with - and / with _ to avoid conflicts with URL special characters — used in JWT tokens, OAuth tokens, and URL parameters. MIME Base64 (used in email) inserts line breaks every 76 characters. Most web APIs and JWT libraries use URL-safe Base64 without padding.

Frequently Asked Questions

What is Base64?
Base64 converts binary data to ASCII text using 64 printable characters. Used for embedding images in HTML/CSS, transmitting binary in JSON, and HTTP Basic Auth headers.
What is URL-safe Base64?
Replaces + with - and / with _ so the encoded string can be safely included in URLs without percent-encoding.
Does Base64 encrypt data?
No. It is encoding, not encryption. Anyone can decode it instantly. Use proper encryption for sensitive data.
How do I encode a file to Base64 in Python?
import base64; encoded = base64.b64encode(open("file.bin","rb").read()).decode("utf-8"). For URL-safe Base64 (used in JWTs): base64.urlsafe_b64encode(data).rstrip(b"=").decode(). To decode: base64.b64decode(encoded_string + "==") (adding padding if removed).
Is Base64 the same as encryption?
No. Base64 is encoding, not encryption. It is trivially reversible — anyone can decode a Base64 string without a key. It is used to represent binary data as text, not to protect it. Never use Base64 to "hide" sensitive data; use proper encryption (AES, RSA) or hashing (bcrypt) depending on the use case.
Related tools
Ad