Developer Tools

Free Base64 Encoder & Decoder

Convert text to Base64 and back with full UTF-8 support. URL-safe mode, line wrapping and file input included — all in your browser.

Live Convert 100% Private Full UTF-8 URL-Safe

Input

0 chars · 0 lines Empty
UTF-8 aware: the encoder handles characters like é, ñ, 中文 and emoji correctly — things that native btoa() throws on.

Output

Output will appear here

What Is Base64?

Base64 is a way of representing binary data using 64 printable ASCII characters: A–Z, a–z, 0–9, + and /. It was designed for systems that can only carry text — email, JSON, XML, HTML attributes and CSS values — but sometimes need to transport binary content.

Base64 is not encryption. It's a lossless encoding — anyone can decode it. It's also not compression — it makes data ~33% bigger. It's just a way to turn binary into text so it can pass through text-only channels without corruption.

The 64-character alphabet

ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/

Every 3 bytes of input (24 bits) become 4 characters of output (24 bits split into 4 × 6 bits). When the input length isn't a multiple of 3, the last group is padded with = characters to keep the output aligned:

Input bytesOutput charsPadding
34None
23 + 1 padOne =
12 + 2 padsTwo ==

Why does btoa() fail on Unicode?

JavaScript's native btoa() function only accepts strings where every character is in the range 0–255 (Latin-1). Any character above that — é, ñ, 中, 😀 — throws:

Uncaught DOMException: Failed to execute 'btoa' on 'Window':
The string to be encoded contains characters outside of the Latin1 range.

This tool avoids the problem by converting the string to UTF-8 bytes first, then feeding those bytes to btoa():

var bytes = new TextEncoder().encode(str);  // string → UTF-8 bytes
var binary = '';
for (var i = 0; i < bytes.length; i++) {
  binary += String.fromCharCode(bytes[i]);
}
var base64 = btoa(binary);

Decoding does the reverse with TextDecoder. The result is correct Base64 for any Unicode string.

Standard vs URL-safe Base64

VariantChars 62 & 63PaddingUsed by
Standard (RFC 4648)+ and /=MIME, data URIs, most APIs
URL-safe (RFC 4648 §5)- and _Often omittedJWT, OAuth, URLs, filenames

The characters +, / and = have special meaning in URLs and filenames, so URL-safe Base64 swaps them out. This tool converts automatically.

Line wrapping (MIME)

Email attachments and some legacy systems expect Base64 output wrapped at 76 characters per line. Other systems require a single long line. The line wrap option is off by default because most modern contexts handle unwrapped output fine.

Common use cases

Data URIs

Embed small images in HTML or CSS as data:image/png;base64,….

HTTP Basic Auth

Encode username:password for the Authorization: Basic header.

JWT Payloads

Inspect or construct the URL-safe Base64 segments of a JSON Web Token.

API Payloads

Send binary data inside a JSON POST body without multipart uploads.

Email Attachments

Encode binary files for MIME transport.

Database Fields

Store small binary blobs in text columns.

Obfuscation

Hide spoilers or simple strings from casual inspection (not real security).

Debugging

Decode a Base64 string you found in a cookie, header or log file.

Privacy and security

This Base64 encoder runs entirely in your browser. Encoding uses native TextEncoder, String.fromCharCode and btoa; decoding uses atob and TextDecoder. Your text never leaves your device. Safe for credentials, API keys, private messages and any other sensitive content.

Frequently Asked Questions

What is Base64 encoding?
Base64 is a way of representing binary data using 64 printable ASCII characters. It's used to embed binary data in text-only formats like HTML, CSS, JSON and XML without corruption.
Does Base64 encoding make files bigger?
Yes. Base64 increases size by roughly 33% because every 3 bytes of binary become 4 ASCII characters. This is inherent to the encoding — no tool can avoid it.
What is URL-safe Base64?
Standard Base64 uses the characters + and / which have special meanings in URLs. URL-safe Base64 replaces + with - and / with _, and often strips the = padding. This makes the output safe to put directly in a URL query string, cookie or filename.
Why does native btoa() fail on Unicode?
JavaScript's native btoa() only handles Latin-1 characters (code points 0–255). Feeding it any Unicode character like é, ñ, or an emoji throws an InvalidCharacterError. This tool uses TextEncoder to convert the string to UTF-8 bytes first, then encodes those bytes.
What is line wrapping?
MIME Base64 (used in email attachments) wraps output at 76 characters per line. Some systems require this; others don't. The option is off by default because most modern contexts handle single-line Base64 fine.
Can I decode Base64 that has whitespace in it?
Yes. The decoder strips all whitespace, newlines, tabs and carriage returns before decoding. It also handles both standard and URL-safe Base64 variants automatically.
Is Base64 a form of encryption?
No. Base64 is not encryption. It's a lossless encoding that anyone can reverse. Never use Base64 to protect sensitive data — use proper encryption like AES or ChaCha20, and always use HTTPS.
Does it handle files, or just text?
You can upload any file (click "Upload"), and it will be read as text and then encoded. For binary files like images, the resulting Base64 is what you'd use in a data URI. For very large files (over a few MB), the browser may be slow — this tool is optimised for text and small binaries.
Is my data uploaded to a server?
No. All encoding and decoding happens locally in your browser. Your text never leaves your device.
Is this Base64 encoder free?
Yes. It is 100% free, requires no sign-up, and runs entirely in your browser.

Related Developer Tools

Done!