Developer

Base64 Encoder / Decoder

Encode and decode Base64 strings instantly

0 characters
Output will appear here...

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.

Frequently Asked Questions

What is Base64 encoding?
Base64 is a binary-to-text encoding scheme that represents binary data using a set of 64 printable ASCII characters (A-Z, a-z, 0-9, +, /). It is used to safely transmit binary data over systems designed to handle text. Base64 encoding increases the data size by approximately 33%.
Why is Base64 used?
Base64 is used when you need to store or transmit binary data (images, files, binary blobs) through systems that only support text, such as: email (MIME encoding), embedding images directly in HTML/CSS (data URIs), JSON payloads that need to include binary data, HTTP headers, JWT tokens, and URL parameters.
Is Base64 a form of encryption?
No — Base64 is encoding, not encryption. It can be decoded by anyone with a Base64 decoder (including this tool). Do not use Base64 to "secure" sensitive data. If you need to protect data, use proper encryption (AES, RSA, etc.). Base64 is only about format transformation, not security.
What is URL-safe Base64?
Standard Base64 uses + and / characters, which have special meaning in URLs. URL-safe Base64 replaces + with - and / with _ to make the encoded string safe for URL parameters and filenames without percent-encoding. JWT tokens and some web APIs use URL-safe Base64 without the = padding.
What is a Data URI and how does it use Base64?
A Data URI embeds file content directly in HTML/CSS rather than referencing an external URL. Format: data:[mediatype];base64,[encoded-data]. Example: <img src="data:image/png;base64,iVBORw0KGgo...">. This eliminates an HTTP request for small images, at the cost of increased page size and no browser caching.
How does Base64 encoding work technically?
Base64 takes every 3 bytes of binary input and encodes them as 4 ASCII characters. It maps each 6-bit group (2^6 = 64 possible values) to one of 64 safe printable characters. If the input length is not divisible by 3, padding characters (=) are added to make the output length divisible by 4.