Encoders

Base64 Encoding Explained - What, Why, and How

Understand Base64 encoding: what it is, why it exists, how it works, and when to use it in web development.

August 3, 20263 min read

What is Base64 Encoding?

Base64 is a binary-to-text encoding scheme that converts binary data into a set of 64 ASCII characters. It's used to safely transmit binary data through text-only channels like email, URLs, and JSON.

How Base64 Works

Base64 takes every 3 bytes (24 bits) of input and splits them into 4 groups of 6 bits each. Each 6-bit group maps to one of 64 characters (A-Z, a-z, 0-9, +, /). If the input isn't divisible by 3, padding (=) is added.

Common Use Cases

  • Data URIs - Embedding images directly in HTML/CSS
  • Email attachments - MIME encoding for binary files
  • API authentication - HTTP Basic Auth uses Base64
  • JWT tokens - Payload is Base64URL encoded

Try It Yourself

Use our Base64 Encoder/Decoder to encode or decode Base64 strings instantly in your browser.

Base64 vs Base64URL

Base64URL replaces + with - and / with _ to make the output URL-safe. This is used in JWTs and data URIs.