Base64 Encoder & Decoder — Free Online Tool

Base64 Encoder & Decoder

Convert text to Base64 and back. Handles full UTF-8 (emoji, accents, CJK) correctly, plus the URL-safe Base64URL variant.

Details

How to use this tool

  1. Pick Encode to turn plain text into Base64, or Decode to turn Base64 back into text.
  2. Type or paste into the input box — the result updates as you type.
  3. Tick Base64URL if the value goes into a URL, a filename, or a JWT segment. This swaps + for -, / for _, and drops the = padding.
  4. Use Swap to move the output back into the input and flip the mode — handy for round-trip checks.
  5. Read the Details panel to see exactly how much the encoding inflated your data.

Base64 encodes arbitrary binary data using only 64 printable ASCII characters, so it can pass safely through systems that were designed for text — email bodies, JSON fields, HTTP headers, XML documents, and data URIs. It takes three bytes of input and represents them as four output characters, which is why Base64 always inflates your payload by roughly 33%.

The single most common bug in Base64 handling is Unicode. JavaScript’s built-in btoa() throws on any character above U+00FF, so naively encoding an emoji or a Chinese character fails outright. This tool routes everything through TextEncoder and TextDecoder first, converting your text to UTF-8 bytes before encoding — which is why the emoji in the default input round-trips correctly here but would break a naive implementation.

Base64URL is a small but important variant defined in RFC 4648. Standard Base64 uses + and /, both of which have reserved meanings in URLs, and = padding, which is awkward in query strings and path segments. Base64URL substitutes - and _ and drops padding entirely. JSON Web Tokens use Base64URL for every segment, so if you are hand-inspecting a JWT you want this checkbox on.

It is worth being blunt about what Base64 is not: it is not encryption, and it offers no security whatsoever. Anyone can decode it instantly — you are doing exactly that on this page. Encoding a password or an API key in Base64 obscures it from a casual glance and from nothing else. HTTP Basic Auth famously sends credentials as Base64, which is precisely why Basic Auth over plain HTTP is unacceptable and why it must always run over TLS.

Where Base64 genuinely earns its keep is embedding. Data URIs (data:image/png;base64,...) let you inline a small image or font directly into HTML or CSS, removing a network round-trip. The tradeoff is the 33% size penalty and the loss of separate caching, so the technique pays off for small assets — icons, tiny logos, a critical font subset — and hurts for anything large.

Frequently asked questions

Why does my emoji or accented character break in other Base64 tools?

Because they call btoa() directly on the string. That function only accepts characters in the Latin-1 range and throws an InvalidCharacterError on anything else. Correct handling means converting the string to UTF-8 bytes first. This tool does that, so emoji, accents, and CJK text all round-trip cleanly.

What is the difference between Base64 and Base64URL?

Only three characters. Base64URL replaces + with - and / with _, and omits the trailing = padding. This makes the output safe to drop into a URL path, query string, or filename without percent-encoding. JWTs use Base64URL throughout.

Is Base64 a form of encryption?

No. It is an encoding, not a cipher — there is no key and no secret. Anything Base64-encoded can be decoded by anyone in under a second. Use it to make binary data text-safe, never to protect it.

Why is my encoded output bigger than the input?

By design. Base64 represents every 3 bytes as 4 characters, a fixed 4/3 ratio, plus up to 2 characters of padding. Expect roughly 33% growth. The Details panel on this page shows the exact figure for your input.

Can I Base64-encode a file or image here?

This tool handles text input. For images and binary files you would need a file picker and a FileReader — that is a separate tool. If you already have the file’s bytes as a string, you can paste them here, but for real files use a dedicated file-to-Base64 converter.