Base64 encoder / decoder

Convert text to Base64 and Base64 back to text.

The interactive form is ready when JavaScript is enabled.

How to use

Base64 rewrites arbitrary bytes using 64 printable characters (A–Z, a–z, 0–9, + and /), so data survives channels that only expect text: an email attachment, a JSON string, a data: URL. Every 3 bytes become 4 characters, so encoding grows the input by about a third.

Text → Base64 encodes your text as UTF-8 first, so accented letters and emoji survive the round trip unchanged. Base64 → Text decodes the string and shows which text encoding it used: UTF-8 when the bytes are valid UTF-8, otherwise Windows-1252, the encoding many older Western files use.

When decoding, spaces and line breaks are ignored, and missing = padding is accepted. The URL-safe variant, which uses - and _ instead of + and /, is not: replace - with + and _ with / first. A data: URL has to be stripped of everything up to and including the comma.

This tool works with text. Decoding the Base64 of an image or another binary file produces unreadable characters, because those bytes are not text in any encoding.

Encoding is not encryption: anyone holding the string can decode it, and it protects nothing. Everything runs in your browser.

Example

Encodes the sample text as Base64. Decode reverses the encoding; Base64 does not encrypt the content.

  • HelloSGVsbG8=
  • Olá 👋T2zDoSDwn5GL
  • SGVsbG8=Hello
  • a / ab / abcYQ== / YWI= / YWJj: one or two = fill a group of three bytes that is not complete.

Frequently asked questions

Is Base64 a way to hide data?

No. It is an encoding, not a cipher, and decoding needs no key. Anything secret has to be encrypted before it is encoded.

What are the trailing = signs?

Padding. Base64 works in groups of three bytes; when the input does not divide evenly, one or two = characters fill the last group. This tool decodes strings with or without them.

Why does decoding fail?

Usually because the string uses the URL-safe characters - and _, still has a data: prefix, or was cut short. A length that leaves one character over a multiple of four cannot be valid Base64.

Why are accented letters wrong after decoding?

The text was probably encoded from a character set other than UTF-8 or Windows-1252, such as an Asian or Cyrillic one. The tool shows which encoding it assumed.

Related tools