What is Base64?

Base64 is an encoding scheme that converts binary data into a string of printable ASCII characters. It is one of the most common encoding formats in web development.

Definition

Base64 encodes binary data by mapping every 3 bytes of input to 4 printable characters chosen from a 64-character alphabet: A–Z, a–z, 0–9, +, and /. The name comes from that alphabet size — 64 characters.

The result is a string that contains no special or unprintable characters, making it safe to include in text-based systems like email, HTML, JSON, or XML.

Example

The text Hello encodes to SGVsbG8= in Base64. The trailing = is padding added when the input length is not a multiple of 3.

Common Uses

  • Email attachments — MIME encoding uses Base64 to embed binary files in text-based email messages.
  • Data URIs — Images and fonts can be embedded directly in HTML or CSS as data:image/png;base64,... URIs.
  • API payloads — Binary data (images, PDFs) is often Base64-encoded before being included in JSON bodies.
  • JWT tokens — The header and payload sections of a JWT are Base64URL-encoded (a URL-safe variant).
  • Config files — Credentials and certificates are frequently stored as Base64 strings in environment variables and config files.

Base64 vs Base64URL

Standard Base64 uses + and / characters, which are not safe in URLs. Base64URL replaces them with - and _ and omits padding. JWTs use Base64URL encoding.

Is Base64 Encryption?

No. Base64 is encoding, not encryption. It provides no confidentiality — anyone can decode a Base64 string instantly without a key. Never use Base64 as a security measure.

Encode or decode Base64 strings instantly in your browser: Open Base64 Encoder / Decoder →

Frequently Asked Questions

Is Base64 encryption?

No. Base64 is encoding, not encryption. It does not protect data — anyone can decode it instantly without a key. It is purely a format conversion.

Does Base64 increase file size?

Yes. Base64 encoding increases the size of the data by approximately 33% because every 3 bytes of input become 4 bytes of output.

What is the difference between Base64 and Base64URL?

Standard Base64 uses + and / which are unsafe in URLs. Base64URL replaces them with - and _ and removes padding. JWTs use Base64URL.

Can I decode any Base64 string?

Yes, as long as the string is valid Base64. There is no key or password — Base64 is reversible by anyone.

Related Terms

  • URL Encoding — Percent-encoding special characters in URLs.
  • JWT — JSON Web Tokens, which use Base64URL encoding.
  • Hash Functions — One-way transformations, unlike reversible Base64.