Base64 Encoder & Decoder — Free Online Tool

Free online Base64 encoder & decoder. Convert text or files to Base64 and back. Supports standard and URL-safe encoding. Everything runs in your browser — your data never leaves your device.

Learn More

What Is Base64 Encoding?

Base64 is a binary-to-text encoding scheme that converts binary data into a string of 64 printable ASCII characters. It is defined in RFC 4648 and is used whenever binary data needs to travel through text-only channels — like email (MIME), JSON APIs, HTML data URIs, or HTTP headers.

The encoding alphabet consists of A–Z, a–z, 0–9, +, and / (plus = for padding). The URL-safe variant (Base64URL) replaces + with - and / with _ to avoid conflicts in URLs and filenames.

Base64 is not encryption. It is a reversible encoding that anyone can decode. Never use Base64 to protect sensitive data like passwords or API keys.

How Base64 Encoding Works

Base64 converts every 3 bytes (24 bits) of input into 4 characters (6 bits each) from the Base64 alphabet. Here is the classic example — encoding the word "Man":

Step 1 — Convert each character to its ASCII byte value:

M
77
a
97
n
110

Step 2 — Convert to binary (24 bits total):

01001101 01100001 01101110

Step 3 — Split into 6-bit groups and map to Base64 characters:

6-bit Group Binary Decimal Base64 Char
1st01001119T
2nd01011022W
3rd0001015F
4th10111046u

Result: "Man""TWFu"

What about padding? If the input length is not a multiple of 3 bytes, Base64 pads the output with = characters. 1 missing byte → ==, 2 missing bytes → =. For example: "Ma""TWE=", "M""TQ==".

Base64 Alphabet Table

The standard Base64 character set maps values 0–63 to these 64 characters:

Value Char Value Char Value Char Value Char
0A16Q32g48w
1B17R33h49x
2C18S34i50y
3D19T35j51z
4E20U36k520
5F21V37l531
6G22W38m542
7H23X39n553
8I24Y40o564
9J25Z41p575
10K26a42q586
11L27b43r597
12M28c44s608
13N29d45t619
14O30e46u62+
15P31f47v63/

URL-safe variant: value 62 maps to - (instead of +) and value 63 maps to _ (instead of /). Padding = is omitted. Use this when embedding Base64 in URLs, filenames, or JWT tokens.

Common Uses of Base64

Base64 encoding appears everywhere in modern web development:

Data URIs in HTML/CSS

Embed images inline: data:image/png;base64,...

Email Attachments (MIME)

Binary files encoded for text-only SMTP transport

JSON & XML Payloads

Store binary data (images, files) in text-based formats

HTTP Basic Auth

Authorization: Basic dXNlcjpwYXNz

JWT Tokens

Header and payload are Base64URL-encoded

Source Maps & Fonts

Inline fonts and source maps in CSS/JS bundles

Base64 Encoding vs Encryption

A common misconception is that Base64 provides security. It does not:

Feature Base64 Encoding Encryption (e.g. AES)
PurposeData transport (binary → text)Data protection (confidentiality)
Reversible?Yes, by anyoneOnly with the key
Key required?NoYes (secret key)
Size overhead~33% largerVaries (block padding)
Use for passwords?NeverUse hashing instead

How to Encode & Decode Base64 in Code

Quick reference for Base64 encoding in the most popular languages:

JavaScript

// Encode
const encoded = btoa("Hello, World!");
// "SGVsbG8sIFdvcmxkIQ=="

// Decode
const decoded = atob("SGVsbG8sIFdvcmxkIQ==");
// "Hello, World!"

// Unicode-safe encode (handles emojis, CJK, etc.)
const utf8 = new TextEncoder().encode("Hello");
const b64 = btoa(String.fromCharCode(...utf8));

Python

import base64

# Encode
encoded = base64.b64encode(b"Hello, World!").decode()
# "SGVsbG8sIFdvcmxkIQ=="

# Decode
decoded = base64.b64decode("SGVsbG8sIFdvcmxkIQ==").decode()
# "Hello, World!"

# URL-safe
url_safe = base64.urlsafe_b64encode(b"data").decode()

Command Line (Linux / macOS)

# Encode
echo -n "Hello, World!" | base64
# SGVsbG8sIFdvcmxkIQ==

# Decode
echo "SGVsbG8sIFdvcmxkIQ==" | base64 --decode
# Hello, World!

# Encode a file
base64 image.png > image.b64

Frequently Asked Questions

What is Base64 encoding?

Base64 is a binary-to-text encoding scheme that represents binary data using 64 printable ASCII characters (A–Z, a–z, 0–9, +, /). It is commonly used to safely transmit binary data over text-based systems like email (MIME), JSON APIs, and HTTP headers. The standard is defined in RFC 4648.

Is Base64 encoding the same as encryption?

No. Base64 is a reversible encoding, not encryption. Anyone can decode a Base64 string without needing a key. Never use Base64 to protect sensitive data like passwords, API keys, or personal information. Use proper encryption (like AES) or hashing (like bcrypt) instead.

Why does Base64 increase file size by 33%?

Base64 converts every 3 bytes of input into 4 ASCII characters. Each character uses 8 bits to represent only 6 bits of actual data. This means the output is always approximately 33% larger than the input (4/3 ratio). Padding characters (=) can add a few extra bytes.

What is URL-safe Base64?

Standard Base64 uses + and / characters, which have special meaning in URLs. URL-safe Base64 (defined in RFC 4648 Section 5) replaces them with - and _, and omits padding. It is used in JWT tokens, URL query parameters, and filenames.

What does the = sign mean in Base64?

The = character is padding. Base64 processes input in groups of 3 bytes. If the input length is not a multiple of 3, the output is padded: 1 byte remaining adds ==, 2 bytes remaining adds =. This ensures the output length is always a multiple of 4.

How do I encode or decode Base64 in JavaScript?

Use btoa() to encode a string to Base64 and atob() to decode. For Unicode text (emojis, CJK characters), first encode to UTF-8 using TextEncoder, then convert the bytes to a binary string before calling btoa(). See the MDN documentation for details.

Can I convert an image to Base64?

Yes. Click the Upload button in the encoder and select an image file. The tool converts it to a Base64 string that you can embed directly in HTML or CSS as a data URI (e.g., data:image/png;base64,...). This eliminates the need for separate HTTP requests but increases the HTML file size by ~33%.

Free tools that respect your privacy

No sign-up. No tracking. Everything runs in your browser.