What is Base64 Encoding?

Base64 is an encoding scheme that represents binary data using 64 printable ASCII characters so it can travel safely through text-only channels.

Base64 is a binary-to-text encoding that converts arbitrary bytes into a string made up of 64 safe characters: A–Z, a–z, 0–9, plus, and slash, with the equals sign used for padding. Its purpose is to let binary data — images, files, cryptographic keys — pass through systems that were designed only for text, such as email bodies, JSON fields, URLs, and HTML attributes.

The mechanism is simple: Base64 takes three bytes (24 bits) of input at a time and re-expresses them as four 6-bit groups, each mapped to one of the 64 characters. Because four output characters represent three input bytes, Base64 always inflates data by roughly 33 percent. That size cost is the trade-off for guaranteed safe transport through text channels.

Base64 shows up constantly in web development. Data URIs embed small images directly in CSS or HTML as base64 strings, JSON Web Tokens encode their header and payload in a URL-safe variant, HTTP Basic Authentication base64-encodes credentials, and email attachments are base64-encoded by the MIME standard. Recognizing a base64 string — often ending in one or two equals signs — helps you decode and inspect these values.

A crucial point: Base64 is encoding, not encryption. It provides no security whatsoever because anyone can decode it instantly. Credentials base64-encoded in an HTTP header are effectively plaintext to anyone who can see the request. Use Base64 to make data transport-safe, and rely on TLS and real cryptography for confidentiality.

Examples

  • 'Hello' encodes to SGVsbG8=
  • A data URI: data:image/png;base64,iVBORw0KGgo... embeds an image inline
  • URL-safe Base64 replaces + and / with - and _ so it fits in query strings

Frequently asked questions

Free tools for working with Base64 Encoding

Related terms