Guide

What is Base64?

A complete guide to Base64 encoding - what it is, how it works, when to use it, and why it is essential for the modern web.

What is Base64 encoding?

Base64 is a binary-to-text encoding scheme that converts binary data into a string of ASCII characters. It uses a set of 64 characters - hence the name - consisting of uppercase letters (A-Z), lowercase letters (a-z), digits (0-9), and two special characters (typically + and /).

The purpose of Base64 is to represent binary data in a format that is safe for transmission through systems designed to handle text. Since many protocols - email, HTTP, JSON, XML - were built around text, binary data (like images or encrypted content) needs to be converted into a text-safe representation.

How does Base64 work?

Base64 encoding works by taking binary data and splitting it into groups of 6 bits, then mapping each 6-bit value to one of 64 printable characters. Here is the process step by step:

  1. Take the input bytes (each byte is 8 bits).
  2. Group the bits into 24-bit chunks (3 bytes at a time).
  3. Split each 24-bit chunk into four 6-bit values.
  4. Map each 6-bit value (0-63) to its corresponding Base64 character using the lookup table.
  5. If the input is not a multiple of 3 bytes, add padding (=) to make the output a multiple of 4 characters.

Example: Encoding "Man"

TextMan
ASCII7797110
Binary010011010110000101101110
6-bit groups010011010110000101101110
Index1922546
ResultTWFu

"Man" → TWFu - 3 bytes become 4 Base64 characters.

Because every 3 input bytes produce 4 output characters, Base64-encoded data is approximately 33% larger than the original binary data. This is the trade-off for text-safe transmission.

Why do we use Base64?

Many systems in computing were designed to handle text only. Binary data can contain byte values that these systems interpret as control characters, causing corruption or failures. Base64 solves this by converting binary data into a safe, predictable set of ASCII characters.

The 64 characters chosen are:

  • Common to virtually all character encodings
  • Printable and human-readable
  • Unlikely to be modified by text-based systems (unlike raw binary)
  • Safe in URLs, JSON, XML, and email headers

Common use cases

Data URIs

Embed images, fonts, or other files directly in HTML and CSS using data:image/png;base64,... URIs. Reduces HTTP requests for small assets.

Email Attachments (MIME)

Email protocols were designed for text. Base64 encodes binary attachments so they survive transit through email servers unchanged.

API Payloads & JSON

JSON cannot hold raw binary. Base64 encodes binary data into a string so it can be sent as part of a REST API request or response.

JWTs (JSON Web Tokens)

JWT payloads use Base64URL encoding to safely include claims, signatures, and headers in URLs and HTTP Authorization headers.

Basic Authentication

HTTP Basic Auth encodes username:password as Base64 in the Authorization header.

Local Storage

Store binary data (like user-uploaded images) in browser localStorage by Base64-encoding it first.

Base64 vs Base64URL

Standard Base64 uses + and / as the last two characters, and = for padding. But these characters have special meanings in URLs:

  • + is interpreted as a space in URLs
  • / is a path separator
  • = is used for query parameters

Base64URL (RFC 4648 §5) replaces + with - and / with _, and the padding = is often omitted. This makes it safe for use in URLs, file names, and JWT tokens. Our Base64 tool supports both variants automatically.

FeatureStandard Base64Base64URL
Characters 62-63+ /- _
Padding= (required)= (optional, often omitted)
URL SafeNo - needs percent-encodingYes - URL-ready
Common inEmail, data URIs, file storageJWTs, OAuth tokens, URL params

Is Base64 encryption?

No. Base64 is NOT encryption. It provides zero security. Anyone can decode a Base64 string back to its original form - there is no key, no password, and no secret involved. Base64 is an encoding, not an encryption algorithm.

Warning: Never rely on Base64 to protect sensitive data. Use proper encryption (AES, RSA, etc.) for security. Base64 only makes data text-safe - it does not hide it.

Frequently asked questions

How much larger is Base64 than the original data?
Base64 encoding increases data size by approximately 33%. Every 3 bytes of input produce 4 bytes of output. For example, a 300 KB image becomes roughly 400 KB when Base64-encoded.
Can Base64 handle any type of file?
Yes. Base64 can encode any binary data - images, PDFs, ZIP files, audio, video, or any arbitrary bytes. The encoding does not care what the data represents; it works at the byte level.
Is this tool free?
Yes, completely free. No sign-ups, no limitations. All encoding and decoding happens directly in your browser - your data is never uploaded to any server.
Does base64go store my data?
Never. Your data stays on your device. We cannot see, access, or store anything you type or upload. The tool runs entirely in your browser using JavaScript - there is no server-side processing at all.

Ready to encode or decode?

Try our free Base64 tool - live, instant, and 100% private.

Open the Tool