Tools

Base64 encoder and decoder

Convert text or files to Base64 and back. Handles Unicode correctly, supports URL-safe output, and turns images into ready-to-paste data URLs.

Encoding and decoding use your browser's own functions. Tokens, keys and files you paste here never leave the page — verify it with the network tab open.

How to use this Base64 tool

The tool has two modes. Text converts between plain text and Base64 in either direction. File / image reads a file from your device and gives you its Base64 representation, optionally wrapped as a data URL you can paste straight into HTML or CSS.

What Base64 is, and what it is not

Base64 represents arbitrary binary data using 64 printable ASCII characters. It exists because many systems — email headers, URLs, JSON string fields, XML documents, HTTP headers — can only carry text safely, and binary bytes passing through them get mangled or rejected.

The cost is size: every three bytes of input become four characters of output, so Base64 data is 33% larger than the original, plus padding. That overhead is the price of transport safety.

The critical thing to understand is that Base64 is not encryption. It is an encoding with no key and no secret. Anyone can decode it instantly — this page does it in a millisecond. A password stored as Base64 is a password stored in plain text with an extra step. It is worth stating because Base64-as-security is a genuinely common mistake in real systems.

Unicode is handled correctly here

A subtle bug affects many Base64 tools and a lot of hand-written JavaScript: the built-in btoa() function only accepts characters in the 0–255 range. Feed it an emoji, a Chinese character, or an accented letter above that range and it throws an error — or worse, silently produces corrupt output.

This tool encodes text to UTF-8 bytes first, then Base64-encodes those bytes. Decoding reverses the process. That means "café", "日本語" and "🎉" all round-trip perfectly, which is what you need when the data is a name, an address or anything written by a human in a language other than English.

URL-safe Base64

Standard Base64 uses + and /, both of which have special meanings inside a URL, and = for padding, which also causes trouble in query strings. URL-safe Base64 — defined in RFC 4648 — substitutes - for + and _ for /, and drops the padding.

Tick the URL-safe box when the output is going into a query parameter, a URL path segment, a cookie value, or a JWT. JSON Web Tokens use URL-safe Base64 for all three of their parts, which is why a JWT never contains a plus sign. Decoding accepts both variants automatically and restores missing padding, so you never have to think about which you have been given.

Files and data URLs

Switch to the file tab and drop in any file. You get its Base64 form, and for images you also get a preview so you can confirm you have the right file.

A data URL is the Base64 with a prefix — data:image/png;base64, — that tells the browser what it is looking at. Paste one into an <img src> attribute or a CSS background-image and the image renders with no separate network request. That is genuinely useful for tiny assets: icons, a 1 KB logo in an HTML email, an SVG in a single-file document, or a placeholder that must appear before anything else loads.

Use it sparingly. Embedded images cannot be cached separately from the document, they inflate your HTML or CSS by a third of the image's size, and they block rendering while the containing file parses. The rough rule: inline anything under about 2 KB, link to anything larger. The tool refuses files above 8 MB, because the resulting string is large enough to make the browser's text rendering crawl.

Where you will actually meet Base64

  • JWT tokens. Three URL-safe Base64 segments separated by dots. Paste the middle one here to read the claims — and note that being able to read them proves the payload is not secret.
  • HTTP Basic authentication. The header is literally Basic base64(username:password), which is exactly why Basic auth over plain HTTP is unacceptable.
  • Email attachments. MIME encodes every binary attachment as Base64, which is why an emailed file arrives roughly a third larger than it left.
  • API keys and certificates. PEM files are Base64-wrapped DER between -----BEGIN----- markers.
  • Images in JSON. APIs that must carry binary through a text-only field Base64 it, though a separate upload endpoint is nearly always the better design.

Privacy

Everything is computed by browser built-ins inside this page. Nothing is uploaded. That is not a minor detail for this particular tool: the strings people decode most often are session tokens, API keys and auth headers, and pasting those into a website that transmits them would be handing over live credentials.

Frequently asked questions

Is Base64 a form of encryption?

No. It is a reversible encoding with no key and no secret — anyone who has the string can decode it instantly. Storing a password or an API key as Base64 provides no security whatsoever. Use real encryption, or hashing for passwords.

Why does Base64 make my file bigger?

Every three bytes of binary data are represented as four ASCII characters, so the output is about 33% larger, plus up to two padding characters. That overhead buys you the ability to send binary data safely through channels that only accept text.

What is URL-safe Base64 and when do I need it?

It replaces + with - and / with _, and drops the = padding, because those three characters have special meanings in URLs. Use it for query parameters, cookies and anything JWT-related. Decoding here accepts both forms automatically.

Can I decode a JWT token with this?

Yes for reading the contents. A JWT is three URL-safe Base64 segments separated by dots — paste the middle segment to see the claims as JSON. This does not verify the signature, so it tells you what a token claims, not whether the claim is authentic.

Why do some Base64 tools break on emoji or accented text?

Because JavaScript's btoa() only accepts characters below code point 256 and fails on anything else. This tool converts text to UTF-8 bytes before encoding, so emoji, CJK characters and accents all round-trip correctly.

Should I embed images as data URLs in my website?

Only very small ones. Data URLs save a network request but cannot be cached independently, inflate your HTML or CSS by a third of the image size, and delay rendering. Inline assets under roughly 2 KB; link to everything larger.