nTropi
Article·

Base64 Encoding: What It Is and When to Use It

Learn why Base64 exists, how it works, and where developers commonly use it in web applications.

The Problem Base64 Solves

Binary data (images, files) cannot be embedded directly in text protocols like HTTP headers, JSON, or HTML. Base64 encodes binary as ASCII text using 64 printable characters.

How It Works

Every 3 bytes of binary become 4 Base64 characters. The alphabet is A-Z, a-z, 0-9, +, /. Padding uses =.

Example: "Hi"SGk=

Common Uses

  • Data URIs: <img src="data:image/png;base64,...">
  • JWT tokens (header + payload are Base64URL encoded)
  • Email attachments (MIME encoding)
  • Embedding fonts in CSS

Base64 vs Base64URL

Base64URL replaces + with - and / with _, making it safe for URLs and filenames without percent-encoding.

Try encoding and decoding instantly with the Base64 Encoder.