🟣"> Base64 Encode and Decode Online — Free Developer Tool (2026) | SPUNK13
Developer Tutorial

Base64 Encode and Decode Online — Free Developer Tool

A complete guide to Base64 encoding and decoding: what it is, how it works, when to use it, and a free tool to do it instantly in your browser.

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 (A-Z, a-z, 0-9, +, /) plus = for padding to represent binary data in a text-safe format.

The name "Base64" comes from the 64-character alphabet used. Every 3 bytes of binary data become 4 Base64 characters. This means Base64-encoded data is about 33% larger than the original, but it is guaranteed to be safe for text-based protocols.

How Base64 Encoding Works (Step by Step)

Let's walk through encoding the string "Hi" in Base64:

Step 1: Convert to Binary

H = 72  = 01001000
i = 105 = 01101001

Step 2: Concatenate the Binary

01001000 01101001

Step 3: Split Into 6-Bit Groups

010010 000110 1001(00)  ← padded with zeros to complete the group

Step 4: Convert Each Group to Base64 Character

010010 = 18 = S
000110 = 6  = G
100100 = 36 = k

Step 5: Add Padding

Since the input was 2 bytes (not divisible by 3), one = padding character is added:

"Hi" → "SGk="
Key insight: Base64 is encoding, not encryption. It provides zero security. Anyone can decode Base64 instantly. Never use it to hide sensitive data.

When to Use Base64 Encoding

1. Embedding Images in HTML/CSS

Data URIs let you embed small images directly in your code, eliminating an HTTP request:

<img src="data:image/png;base64,iVBORw0KGgo..." />

This is useful for small icons (under 5KB). For larger images, a separate file is more efficient because browsers can cache it independently.

2. Email Attachments (MIME)

Email protocols (SMTP) were designed for text. Binary attachments — images, PDFs, archives — are Base64-encoded before being embedded in the email body. Your email client handles this automatically, but understanding it helps when debugging email delivery issues.

3. API Authentication

HTTP Basic Authentication sends credentials as a Base64-encoded string in the Authorization header:

Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=

Decoding dXNlcm5hbWU6cGFzc3dvcmQ= gives username:password. This is why HTTPS is mandatory when using Basic Auth — Base64 provides no security.

4. Storing Binary Data in JSON

JSON does not support binary data natively. If you need to include a file, image, or binary blob in a JSON payload, Base64 encoding is the standard approach:

{
  "filename": "document.pdf",
  "content": "JVBERi0xLjQKMSAwIG9iago8P..."
}

5. JWT Tokens

JSON Web Tokens use Base64URL encoding (a URL-safe variant) for the header and payload sections. If you have ever inspected a JWT, the three dot-separated sections are each Base64URL-encoded JSON.

6. Data URLs in Web Development

Beyond images, data URLs can embed fonts, SVGs, audio, and other resources directly in CSS or HTML. This reduces HTTP requests at the cost of larger file sizes and no caching.

Base64 in Different Programming Languages

JavaScript (Browser)

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

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

Python

import base64

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

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

Node.js

// Encode
const encoded = Buffer.from("Hello, World!").toString("base64");

// Decode
const decoded = Buffer.from("SGVsbG8sIFdvcmxkIQ==", "base64").toString();

Command Line

# Encode (macOS/Linux)
echo -n "Hello, World!" | base64

# Decode
echo "SGVsbG8sIFdvcmxkIQ==" | base64 --decode

Base64 vs Base64URL

Standard Base64 uses + and / characters, which have special meaning in URLs. Base64URL replaces these with - and _, making the output safe for use in URLs, filenames, and query parameters without additional encoding.

JWT tokens use Base64URL. URL parameters use Base64URL. Standard Base64 is fine for everything else.

Common Mistakes

Using Base64 for Security

Base64 is not encryption. It is trivially reversible. Never Base64-encode passwords, API keys, or secrets and assume they are protected. Use proper encryption (AES-256, for example) if you need to protect data.

Base64-Encoding Large Files

Base64 increases data size by approximately 33%. A 1MB image becomes 1.33MB when Base64-encoded. For large files, this overhead is significant. Use Base64 for small assets only; serve large files as regular binary downloads.

Double Encoding

Encoding something that is already Base64-encoded does not provide any benefit. It just wastes space. If your Base64 string looks wrong (too long, unusual characters), check if it was accidentally encoded twice.

Use the Free Base64 Tool

Our Base64 Encoder/Decoder handles both encoding and decoding in your browser. Paste text or Base64, click the button, get your result. No server involved, no tracking, no signup.

You can also use the advanced Base64 tool for file encoding, URL-safe mode, and batch operations.

Related Developer Tools

Encode or Decode Base64 Instantly

Free. No signup. No tracking. Runs in your browser.

Open Base64 Tool

Explore all 300+ free developer tools on spunk.codes.