You've probably seen strings like SGVsbG8gV29ybGQ= in API responses, email headers, or browser URLs. That's Base64. This guide explains what Base64 encoding is, why it exists, and how to encode and decode it instantly online.
⚡ Free Base64 Encoder / Decoder
Encode text, URLs, or images to Base64 — or decode any Base64 string. Instant, free, private.
Open Base64 Tool →What Is Base64?
Base64 is an encoding scheme that converts binary data into a string of 64 printable ASCII characters. The 64 characters are:
- Uppercase letters:
A–Z(26) - Lowercase letters:
a–z(26) - Digits:
0–9(10) - Two symbols:
+and/(2) - Padding character:
=
The encoding works by taking every 3 bytes (24 bits) of input and splitting them into four 6-bit groups. Each 6-bit group maps to one of the 64 characters.
Why Is Base64 Used?
Some protocols (like email via SMTP, or certain HTTP headers) were designed to handle only text, not arbitrary binary data. Base64 solves this by representing any binary data as safe, printable text. Common use cases include:
1. Embedding images in HTML/CSS
Instead of referencing an image file, you can embed it directly using a Data URL:
<img src="data:image/png;base64,iVBORw0KGgo..." />
This reduces HTTP requests but increases file size. Use the Image to Base64 Converter for this.
2. API authentication
HTTP Basic Authentication encodes credentials as Base64:
Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=
Note: Base64 is not encryption. Anyone can decode it. Always use HTTPS.
3. Email attachments (MIME)
Email attachments are encoded in Base64 so binary files (PDFs, images) can travel through text-based email protocols.
4. JWT tokens
JSON Web Tokens use Base64URL (a URL-safe variant) to encode the header and payload. Use the JWT Decoder to inspect them.
5. Storing binary data in JSON or XML
Since JSON strings must be valid Unicode text, binary data (images, files) must be Base64-encoded before embedding.
Base64 Encoding Example
Let's encode the word "Hello":
| Character | ASCII (decimal) | Binary (8-bit) |
|---|---|---|
| H | 72 | 01001000 |
| e | 101 | 01100101 |
| l | 108 | 01101100 |
| l | 108 | 01101100 |
| o | 111 | 01101111 |
The 5 bytes (40 bits) are grouped into six 6-bit chunks, mapped to Base64 characters, and padded with = to make the output a multiple of 4: SGVsbG8=
How to Encode Base64 Online
- Go to the QuickTools Base64 Tool
- Select Encode mode
- Type or paste your text
- The Base64 output appears instantly
- Click Copy
How to Decode Base64 Online
- Go to the QuickTools Base64 Tool
- Select Decode mode
- Paste the Base64 string (e.g.
SGVsbG8=) - The decoded text appears instantly
If the Base64 string decodes to binary (not readable text), the tool will indicate that the output is binary data.
Base64 vs Base64URL
Standard Base64 uses + and /, which have special meaning in URLs. Base64URL replaces them with - and _, making encoded strings safe to use in URLs and filenames without percent-encoding.
| Variant | Special chars | Use case |
|---|---|---|
| Base64 | +/= | Email, general encoding |
| Base64URL | -_ (no padding) | JWT, URLs, filenames |
Base64 in JavaScript
// Encode
const encoded = btoa("Hello World");
// → "SGVsbG8gV29ybGQ="
// Decode
const decoded = atob("SGVsbG8gV29ybGQ=");
// → "Hello World"
Note: btoa() only works with Latin-1 characters. For Unicode strings, encode to UTF-8 bytes first.
Base64 in Python
import base64
# Encode
encoded = base64.b64encode(b"Hello World").decode()
# → 'SGVsbG8gV29ybGQ='
# Decode
decoded = base64.b64decode("SGVsbG8gV29ybGQ=").decode()
# → 'Hello World'
Frequently Asked Questions
Encode or decode Base64 now
Free, instant, and private — runs entirely in your browser.
Open Base64 Tool →