Base64 Encode/Decode

Encode and decode Base64 strings online. Supports text and UTF-8. Free browser-based tool.

What is Base64?

Base64 is a binary-to-text encoding scheme that represents binary data as ASCII strings. It's commonly used to embed images in HTML/CSS, encode email attachments, and transmit data in URLs and APIs.

Features

  • Encode — Convert text to Base64
  • Decode — Convert Base64 back to text
  • UTF-8 support — Handles Unicode characters correctly
  • Privacy — All processing happens in your browser

Tutorial

How to Encode Base64 Online: A Complete Guide

Learn how to encode and decode Base64 strings online in seconds. Step-by-step tutorial with real-world use cases for APIs, images, and email attachments.

Read Guide →

Video Tutorial

2:32

Video coming soon — full transcript available below

Chapters

Full transcript searchable
0:00

What is Base64 and why developers need it

Welcome to this tutorial on Base64 encoding. Base64 is a binary-to-text encoding scheme that converts binary data into ASCII text. It's used whenever you need to transmit binary data over systems that only handle text — like HTTP headers, JSON payloads, XML documents, or email. Common uses include encoding images as data URIs for CSS backgrounds, embedding file attachments in email, passing binary blobs in REST API requests, and storing binary data in JSON. Base64 increases data size by about 33 percent, so it's used for transport, not storage.

0:35

Encoding text to Base64

Open the Base64 Encoder on ToolPilot.dev. In the input textarea, type or paste the text you want to encode. Click the Encode button. The Base64-encoded output appears instantly in the output box. You can encode any text including Unicode characters, JSON strings, or plain text. The encoded result uses only characters A-Z, a-z, 0-9, plus, slash, and equals sign for padding. This makes the output safe to include in URLs, HTML attributes, and JSON values.

1:10

Decoding Base64 back to text

To decode, paste a Base64 string into the input field and click Decode. The original text appears in the output. This is useful when you receive Base64-encoded data from an API response or auth token. Note that Base64 is an encoding, not encryption — anyone can decode it, so never use it for security. Common Base64-encoded values you might decode include Basic Auth headers (where username:password is encoded), JWT payload sections, and data URIs.

1:45

Use case: embedding images in HTML/CSS

One popular use case is embedding small images directly in HTML or CSS using data URIs. Instead of linking to an external image file, you encode the image bytes as Base64 and embed them inline. This eliminates an HTTP request. For example: background-image: url('data:image/png;base64,iVBORw0KGgo...') — the long string after the comma is the Base64-encoded PNG. The Image to Base64 tool on ToolPilot.dev is specialized for this use case and handles image files directly.

2:15

Use case: API authentication headers

HTTP Basic Authentication encodes credentials as Base64. When you call an API with basic auth, the Authorization header looks like: Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ= — where the value is Base64 of username:password. You can use this tool to decode such headers when debugging API calls, or to generate the header value manually for testing. Just encode your credentials in username:password format.

2:25

Privacy & wrap-up

All encoding and decoding happens locally in your browser — no data is sent to any server. This is important since you might encode sensitive strings like API keys or passwords for debugging. The tool uses the built-in browser atob() and btoa() functions for standard Base64, and handles Unicode correctly using TextEncoder. Visit ToolPilot.dev for this tool and 19 other free developer utilities.

Transcript covers all 6 chapters (2:32 total).

Benchmark

Fastest Base64 Encoder Comparison 2026

We tested this tool vs base64.guru, base64encode.org, and CyberChef — 1,000 iterations, Unicode edge cases, privacy analysis.

See Results →

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 used to safely transmit binary data through systems that handle only text.
What is Base64 used for?
Base64 is used for encoding email attachments (MIME), embedding images in CSS/HTML as data URIs, passing binary data in JSON APIs, storing credentials in HTTP Basic Auth headers, and encoding JWTs.
How do I encode text to Base64?
Paste your text into the input field on the Base64 Encoder tool, then click 'Encode to Base64'. The encoded output appears instantly in the output field ready to copy.
How do I decode a Base64 string?
Paste the Base64 string into the input field and click 'Decode from Base64'. The tool decodes it back to the original text. For JWT tokens, use the dedicated JWT Decoder at toolpilot.dev/tools/jwt-decoder/.
Is Base64 encryption?
No. Base64 is encoding, not encryption. It is reversible without a key, so it should never be used to protect sensitive data. Use proper encryption (AES, RSA) for security-critical data.
Why does Base64 end with == or =?
Base64 uses padding characters (=) to ensure the encoded output length is a multiple of 4. One '=' means one padding byte was added; '==' means two were added.
What is URL-safe Base64?
URL-safe Base64 replaces '+' with '-' and '/' with '_' to produce strings safe to use in URLs and filenames without percent-encoding. JWTs use URL-safe Base64 encoding.
Can I encode images with this tool?
For image files, use the dedicated Image to Base64 Converter at toolpilot.dev/tools/image-to-base64/ which supports PNG, JPG, GIF, and SVG uploads and generates ready-to-use data URIs.
Does Base64 increase data size?
Yes. Base64 encoding increases data size by approximately 33% because every 3 bytes of input become 4 characters of output.
How do I use Base64 in JavaScript?
In JavaScript, use btoa() to encode: btoa('hello') returns 'aGVsbG8='. Use atob() to decode: atob('aGVsbG8=') returns 'hello'. For binary data, use the FileReader API or Buffer in Node.js.

Code Examples

Ready-to-use implementations in popular programming languages. Copy, paste, and run.

Base64 Encode/Decode in JavaScript
// Encode a string to Base64
const encoded = btoa('Hello, World!');
console.log(encoded); // SGVsbG8sIFdvcmxkIQ==

// Decode Base64 back to string
const decoded = atob('SGVsbG8sIFdvcmxkIQ==');
console.log(decoded); // Hello, World!

// Handle Unicode strings (UTF-8 safe)
const utf8Encode = btoa(unescape(encodeURIComponent('Hello')));
const utf8Decode = decodeURIComponent(escape(atob(utf8Encode)));

Related Workflow Guides

Compare with alternatives