FREE TOOL · 100% IN-BROWSER · NO SIGNUP

Base64 Encoder / Decoder

Encode or decode Base64 instantly — unicode-safe with full emoji and UTF-8 support, a URL-safe toggle, and live byte stats. Everything runs in your browser, so your text never leaves your device.

Base64 input

URL-safe alphabet

Uses - & _ and drops = padding.

Example — enter your own text above to encode it.
encodeStandard

Base64 output

SGVsbG8sIFNlbWx5UHJvISDimJUgQmFzZTY0IGlzIHVuaWNvZGUtc2FmZS4=
Input bytes44Output chars60Output bytes60
The Complete Guide

Base64 Encoding Explained: How It Works, When to Use It, and the UTF-8 Trap

5 MIN READ

Understand with AI

Discuss with your preferred AI assistant

+33%
Size overhead

Base64 output is always about a third larger than the input because 3 bytes become 4 characters.

64
Alphabet size

The encoding uses exactly 64 safe printable characters, plus = for padding — hence the name.

100%
Stays in your browser

This tool encodes and decodes entirely client-side — your text is never uploaded to a server.

Base64 is one of the most quietly ubiquitous technologies on the web. Every time you embed an image directly in a stylesheet, send an attachment by email, or store a token in a cookie, there is a good chance Base64 is doing the heavy lifting behind the scenes. Yet despite being everywhere, it is widely misunderstood — most notably as a form of "encryption," which it absolutely is not.

This guide explains exactly what Base64 is, when you should reach for it, how to use it safely with international characters and emoji, and the difference between standard and URL-safe variants. By the end you will know how to encode and decode confidently — and avoid the bugs that catch out even experienced developers.

What Is Base64?

Base64 is a binary-to-text encoding scheme. It takes arbitrary binary data — bytes that may include control characters, null bytes, or anything else — and represents it using only 64 "safe" printable ASCII characters: A–Z, a–z, 0–9, plus + and /. A trailing = is used as padding.

The purpose is transport, not secrecy. Many systems — older email protocols, URLs, JSON fields, HTTP headers — were designed to carry text, not raw bytes. Pushing binary data through them unchanged can corrupt it. Base64 sidesteps this by re-expressing the data in characters those systems are guaranteed to pass through unharmed.

How Base64 Encoding Works

The mechanism is elegantly simple. Base64 takes the input three bytes at a time — that is 24 bits — and slices those 24 bits into four groups of six bits. Each 6-bit group is a number from 0 to 63, which maps to one character in the Base64 alphabet.

Because three bytes become four characters, Base64 output is always about 33% larger than the input. When the input length is not divisible by three, the encoder pads the final group with = characters so the output length stays a multiple of four. That is why you so often see one or two equals signs at the end of an encoded string.

Input bytesOutput charactersPadding
3 bytes4 charsnone
2 bytes3 chars + =one
1 byte2 chars + ==two

Unicode and the UTF-8 Trap

Here is the single most common Base64 bug. The classic browser functions btoa() and atob() only handle characters in the Latin-1 range (code points 0–255). Feed them an emoji, an accented letter, or a Chinese character and they throw an error or silently mangle the data.

The fix is to encode in two stages. First convert your text to UTF-8 bytes, then Base64-encode those bytes. Decoding reverses the process: Base64 back to bytes, then interpret the bytes as UTF-8. Our tool does this automatically using the browser's TextEncoder and TextDecoder, so "Héllo 🌍" round-trips perfectly. Always assume text is Unicode unless you have a specific reason not to.

Standard vs URL-Safe Base64

Standard Base64 uses + and /, but both characters have special meaning in URLs and filenames — / is a path separator and + can be read as a space. The URL-safe variant (defined in RFC 4648) swaps them for - and _, and usually drops the = padding too.

  • Use standard Base64 for email attachments, embedded images (data: URIs), and general data transport.
  • Use URL-safe Base64 for query parameters, JWTs (JSON Web Tokens), filenames, and anything that travels in a URL path.

When decoding, you rarely need to know which variant you have — a good decoder accepts both alphabets and tolerates missing padding. Our tool does exactly that.

When to Use Base64 (and When Not To)

Reach for Base64 when you need to move binary data through a text-only channel: inlining small images or fonts to cut HTTP requests, embedding a logo in an email, encoding credentials for HTTP Basic Auth, or stashing a small blob in a JSON payload or cookie.

  • Do not use it for security. Base64 is trivially reversible — anyone can decode it instantly. It is encoding, not encryption.
  • Do not use it for large files. The 33% size increase and added parsing cost make it a poor fit for anything beyond small assets.
  • Do not assume it compresses. Base64 always makes data bigger, never smaller.

Base64 in SEO and Web Performance

For technical SEO, Base64 is a double-edged sword. Inlining a tiny critical icon as a data: URI removes a render-blocking request and can nudge your Largest Contentful Paint in the right direction. But inlining a large hero image bloats the HTML, delays first paint, and cannot be cached separately by the browser. The rule of thumb: inline only assets under a few kilobytes, and keep everything else as cacheable external files.

Expert Tips

Encode UTF-8, not characters

For any text with emoji or non-English characters, convert to UTF-8 bytes before encoding. Skipping this step is the number-one cause of garbled Base64 — this tool does it for you automatically.

Pick the right alphabet

Use standard Base64 for email and data URIs, and URL-safe Base64 for anything that lives in a URL, filename, or JWT. The wrong variant in a URL can silently corrupt your data when + is read as a space.

Frequently Asked Questions

Is Base64 encryption?

No. Base64 is an encoding, not encryption. It provides zero security or secrecy — anyone can decode a Base64 string instantly with no key or password. Never use it to protect passwords, tokens, or sensitive data; use real encryption such as AES for that.

Why is my Base64 output larger than the input?

Base64 represents every three bytes of input with four output characters, so the encoded result is always roughly 33% larger than the original. This overhead is the cost of making binary data safe to transport through text-only systems.

How do I Base64-encode emoji or non-English text safely?

Convert the text to UTF-8 bytes first, then Base64-encode those bytes — never feed raw Unicode to the legacy btoa() function. This tool handles the UTF-8 step automatically, so emoji and accented characters encode and decode without corruption.

What is the difference between standard and URL-safe Base64?

Standard Base64 uses the + and / characters plus = padding. URL-safe Base64 replaces + with - and / with _ , and typically omits padding, so the result can be dropped into URLs, filenames, and JWTs without escaping.

Related guides

Related tools