Base64 Encoder / Decoder
Encode and decode Base64 strings instantly
What is Base64 and Why Does It Exist?
Base64 was invented to solve a fundamental problem: many data transmission systems — email, XML, HTML, JSON, URLs — were designed to handle text, not arbitrary binary data. When you try to send a binary file (image, audio, executable) through a text-only system, bits get corrupted because certain byte values have special meanings (null terminators, line endings, control characters).
Base64 solves this by converting binary data into a safe subset of printable ASCII characters. The tradeoff is a ~33% increase in size (3 binary bytes → 4 ASCII characters), but the data can be safely transported through any text-based system.
Common Uses of Base64 in Web Development
- JWT Tokens: JSON Web Tokens use URL-safe Base64 to encode the header and payload. When you see a JWT like "eyJhbGci...", the part before the first dot is Base64-encoded JSON. You can paste it into this decoder to read the contents.
- Data URIs: Embedding images directly in HTML/CSS as data:image/png;base64,[data]. Useful for icons and small images that would otherwise require an HTTP request.
- Email attachments: MIME (Multipurpose Internet Mail Extensions) uses Base64 to encode attachments in email messages.
- API responses: Many APIs return binary data (thumbnails, documents, signatures) encoded in Base64 within JSON responses.
- HTTP Basic Auth: The Authorization header uses Base64: "Authorization: Basic [base64(username:password)]".
- Cryptographic signatures: Public keys, certificates (PEM format), and digital signatures are commonly stored as Base64-encoded DER data.
Standard vs. URL-Safe Base64
Standard Base64 uses these 64 characters: A-Z (26), a-z (26), 0-9 (10), + (1), / (1), with = for padding.
The problem: + means "space" in URL query strings, and / is a path separator. URL-safe Base64 solves this by substituting: + → -, / → _. Padding (=) is often omitted in URL-safe variant.
When to use each: Use standard Base64 for email, file storage, and most non-URL contexts. Use URL-safe Base64 for URL parameters, JWT tokens, and filenames.
Detecting Base64 Encoded Strings
You can identify Base64 strings by these characteristics:
- Contains only A-Z, a-z, 0-9, +, /, and = (or - and _ for URL-safe)
- Length is a multiple of 4 (with = padding)
- Ends with 0, 1, or 2 equal signs (=) as padding
- Looks like a long string of random-seeming characters
Common Base64 prefixes that hint at content type: "/9j/" = JPEG image, "iVBOR" = PNG image, "JVBER" = PDF, "UEsDB" = ZIP file.