Base64 encoder / decoder

Convert text to Base64 and back. Input is treated as UTF-8, so Chinese, emoji and accents survive the round trip — with an optional URL-safe alphabet.

How to use

  • Put your text on the left and press Encode — the Base64 appears on the right.
  • Put Base64 on the right and press Decode — the original text comes back on the left.
  • With the URL-safe alphabet the output never contains +, / or =, so it can go straight into a URL or a filename.

Why many online Base64 tools mangle non-ASCII text

The browser's btoa() only accepts Latin-1. Feed it any non-ASCII character and it either throws or silently produces garbage. The correct order is: encode the string to UTF-8 bytes first, then Base64 those bytes. That is what this tool does, so café comes out as Y2Fmw6k= instead of mojibake.

Where you actually need it

  • HTTP Basic auth: Authorization: Basic base64(user:password).
  • Data URLs: data:image/svg+xml;base64,... inlines a small asset and saves a request.
  • JWT payloads: the middle segment of a token is Base64URL-encoded JSON.
  • Moving data through text-only channels: config values, headers, CI variables.

One caution

Base64 is encoding, not encryption. Anyone can reverse it in a second, so it protects nothing. It also inflates payloads by roughly 33%, which makes it a poor fit for large data.

Edge cases worth knowing

  • Padding tells you the input length. No trailing = means the input was a multiple of 3 bytes; one = means 2 bytes were left over; two means 1. A Base64 string whose length is not a multiple of 4 after accounting for padding is malformed.
  • Whitespace is usually safe to ignore. Email standards wrap Base64 at 76 columns; most decoders (including this one) skip spaces and newlines. A few strict ones do not — strip whitespace if a decoder rejects input that "looks right".
  • Standard vs URL-safe alphabets. +// belong to the standard alphabet, -/_ to the URL-safe one (JWTs use it). Mixing them breaks decoding; the fix is a one-character substitution, not re-encoding the original.
  • Missing padding can be inferred. Some decoders accept unpadded URL-safe Base64 and reconstruct the padding from the length. Others refuse. If an API rejects your token, try appending the correct number of =.
  • Double encoding. If decoded output still looks like Base64, the original was encoded twice — VGhpcyBpcyBhIHRlc3Q= becoming Vkdo...=-style strings. Decode again.
  • Zero-length input. An empty string encodes to an empty string, not to padding — a surprising corner that catches validation logic.

FAQ

Decoding fails — what now?

Check for spaces, line breaks or a truncated string first. URL-safe Base64 also fails until you switch the alphabet, because - and _ are not valid standard characters.

Can it convert image files?

This version works on text. Image to Base64 (or back) is a common request — send it through the contact page and it will be considered.

Does the encoded result get uploaded?

No. Everything is computed in your browser; no request is made.

Other tools