🔐 What Is Base64 Encoding and When to Use It

Why it's used in email attachments & data URIs

If you've ever spotted a strange string made only of letters, digits, +, /, and = in a config file or API response, it's almost certainly Base64. This guide explains exactly what Base64 does, why it's used, and why it can never serve as a security measure.

What Base64 actually does — binary into text

Base64 converts arbitrary binary data into plain ASCII text so it can travel unbroken through systems that only safely handle text — email, JSON, URLs. As the name suggests, it represents data using just 64 characters (A-Z, a-z, 0-9, +, /). The mechanism is simple: source bytes are grouped 3 at a time (24 bits), split into four 6-bit chunks, and each 6-bit value (0–63) is mapped to one character from that 64-character table. That's why "3 bytes become 4 characters," and why encoded output ends up roughly 33% larger than the original. When the final group doesn't fill a full 3 bytes, the leftover space is padded with = characters.

A real encoding example

The text Man is exactly 3 bytes (M=77, a=97, n=110), so it encodes cleanly to 4 characters: TWFu. Hello, on the other hand, is 5 bytes — it doesn't divide evenly into groups of 3 — and encodes to SGVsbG8=. That trailing = is padding for the incomplete final group. Decoding simply reverses the process, turning each group of 4 characters back into 3 bytes.

Why it's used — text-only pipes

Base64 is widespread because a lot of internet infrastructure was originally designed to carry text only:

Base64 is not encryption

This is the single most important thing to remember. Base64 only changes how data is represented — it requires no key and no secret. Anyone holding the encoded string can restore the original instantly, with nothing more than a one-line snippet in a browser console. So wrapping a password, API key, or personal data in Base64 does not "hide" it — don't mistake it for protection. If a value genuinely needs to stay confidential, you need real encryption (like AES) or, better, a design that avoids transmitting or storing the value at all. Base64 exists purely to move binary data safely through text-only pipes — nothing more.

Want to encode text into Base64 or find out what an unfamiliar Base64 string actually contains? You can do that instantly with our free tool.

Base64 alphabet (64 indices)

Base64 maps each 6-bit value (0–63) to one of the 64 characters below, encoding 3 bytes (24 bits) as 4 characters.

IndexCharacter
0 – 25A – Z
26 – 51a – z
52 – 610 – 9
62+
63/

Standard Base64 vs Base64URL

AspectStandard Base64Base64URL
Char 62+-
Char 63/_
Paddinguses =usually omitted
Main useMIME, email attachments, data URIsURLs, filenames, JWT

+, /, and = are special characters in URLs, so URLs and JWTs use Base64URL, which replaces them with - and _ and omits padding.

🔐 Try it yourself with the tool

What Is Base64 Encoding and When to Use It — Why it's used in email attachments & data URIs

More guides

🔁
How to Find a Domain's IP Address
Find the real server IP a domain points to
🛰️
How to Check DNS Propagation (What Is TTL?)
Understand TTL and check propagation after a nameserver change
📡
The Easiest Way to Find Your IP Address
Public vs private IP, and how to check yours
📐
CIDR Notation and How to Calculate a Subnet Mask
Convert CIDR notation like /24 into a subnet mask
🩺
How to Check an SSL Certificate's Expiration Date
Check a certificate's expiry without opening a browser
🪪
Understanding JWT Structure and How to Decode It
The Header, Payload & Signature — explained
🗝️
How to Create an Apache .htpasswd File for Basic Auth
Generate an APR1-MD5 hashed .htpasswd file
🔑
What Makes a Strong Password (and How to Generate One)
Length, character sets & entropy explained
📘
Using a JSON Formatter to Read API Responses
Turn minified JSON into something readable
🗓️
How to Convert a Unix Timestamp to a Date
Turn seconds-since-1970 into a readable date
🗃️
How to Format Messy SQL Queries
Break a one-line SQL statement into readable clauses
🎨
Converting Between HEX, RGB, and HSL Color Codes
The difference between the three formats
🔠
camelCase, snake_case & Other Naming Conventions
When to use each naming style
🆚
How to Compare Two Text Files (Diff Checker)
Quickly spot differences between two versions