Skip to main content

Base64 Encode/Decode

Encode text to Base64 or decode it back.

Text or Base64 input

Ln 1, Col 1
Base64

Result

Your result will appear here

Add Base64 above, then choose Convert.

Add Base64 on the left, then choose Convert.

Waiting for input

Encode text to Base64 or decode Base64 back to text as UTF-8, with an option for the URL-safe Base64URL alphabet.

What is Base64 Encode/Decode?

Base64 Encode/Decode is a free online tool that encodes text as Base64, or decodes Base64 back to text, in your browser. The text is read and written as UTF-8, so accented letters and emoji survive the round trip, and you can choose the standard alphabet or the URL-safe Base64URL alphabet when you encode.

It either converts the whole input or refuses and tells you what is wrong, with the position of an invalid character.

What it supports

  • Encoding: any text. It is turned into UTF-8 bytes and written as Base64 on a single line, with no line breaks added.
  • Standard alphabet: A to Z, a to z, 0 to 9, + and /, with = padding at the end so that the length is a multiple of 4, as RFC 4648 defines it.
  • URL-safe alphabet (Base64URL): - and _ instead of + and /, and no = padding. It is the form used in JWTs and in many URLs. It is offered only while you encode.
  • Decoding accepts either alphabet, even mixed, ignores spaces and line breaks, and does not need the = padding. The decoded bytes must be valid UTF-8 text.
  • A character that is not in either alphabet, an = in the middle of the text and more than two = at the end are refused, with the line and column of the problem.
  • Text with an unpaired surrogate (half of an emoji) cannot be turned into UTF-8, so encoding it is refused, with its line and column.

Good to know

  • Base64 is an encoding, not encryption: anyone can decode it, so it does not protect anything.
  • Decoding gives text only. If the Base64 holds a file, such as an image or a PDF, its bytes are usually not valid UTF-8 text, and the tool refuses; it does not show or save binary data.
  • A data address such as data:image/png;base64, is not removed. Paste only the part after the comma, or the colon is refused as an invalid character.
  • A length that leaves a single character over (not counting =), and decoded bytes that are not valid UTF-8, are refused without a position, because they concern the text as a whole.
  • Base64 makes data about a third larger, so encoding a large text can pass the result size limit. It is then refused with an incomplete preview (see below).

How do I use Base64 Encode/Decode?

  1. Paste or type your text, or your Base64, in the input box. Nothing runs while you type.
  2. Under “Mode”, choose “Encode” to turn text into Base64 or “Decode” to turn Base64 into text. While you encode, “Alphabet” lets you choose “Standard (Base64)” or “URL-safe (Base64URL)”. Then press “Convert”.
  3. Read the result next to your input. If the Base64 cannot be decoded, the message says why and, for a character that does not belong, gives its line and column.
  4. Press “Copy” to put the result on your clipboard, or “Download” to save it as converted.txt.

Examples

Encode text

Leave “Mode” on “Encode” and “Alphabet” on “Standard (Base64)”, paste this text and press “Convert”. The text is turned into UTF-8 bytes first, which is why “á” takes two bytes before it is encoded.

Olá, mundo!
T2zDoSwgbXVuZG8h

Text that is not Base64

Choose “Decode” and press “Convert”. The comma is not part of the Base64 alphabet, so the tool refuses and gives its line and column. Base64 uses only letters, digits, + and / (or - and _), with = at the end, and spaces and line breaks are ignored.

Hello, world!

This character is not valid in Base64. Base64 uses only letters, digits, + and / (or - and _ in the URL-safe form), with = padding at the end. Spaces and line breaks are ignored.

Line 1, column 6

URL-safe output

With “Alphabet” on “URL-safe (Base64URL)”, + becomes - and / becomes _, and the = padding at the end is left out, so the result can go straight into a URL or a file name. The standard alphabet gives Pj4+Pw== for the same text.

>>>?
Pj4-Pw

Line breaks and missing padding

Choose “Decode”. Spaces and line breaks are ignored and the = padding at the end is not needed, so Base64 that was wrapped over several lines, or written in the URL-safe form without padding, still decodes.

SGVsbG8s
IFdvcmxkIQ
Hello, World!

Binary data

Choose “Decode”. This Base64 holds the first bytes of a PNG image, which are not text, so the tool refuses instead of showing wrong characters. It decodes text only, not files.

iVBORw0KGgo=

The decoded bytes are not valid UTF-8 text, so they cannot be shown as text. This tool decodes text only. The Base64 may hold a file or other binary data, or it may be damaged.

Limits and privacy

Size limits

  • Input: up to 2,000,000 bytes of UTF-8 text (about 2 MB). Accented letters and emoji take more than one byte each. Larger input is rejected.
  • Result: also up to 2,000,000 bytes. If the complete result would be larger, the tool shows only an incomplete preview of the first 100,000 bytes, and that preview cannot be copied or downloaded.
  • Time: a run that takes longer than its time limit is stopped. Try a smaller input.

Is my text sent to a server?

No. The text you type or paste, or open from a local file, is processed locally in your browser, in a dedicated Web Worker. It is never uploaded or sent to the server (a file you open is read in your browser only), and it is not written to storage, cookies or the address bar.

“Copy” puts the result on your clipboard and “Download” saves it as a file, but only when you press the button. The file is created in your browser, so nothing is uploaded.

For the full details, see the Privacy Policy

Related tools and pages

Your text stays in the page when you switch tools in the same tab, so you can try the same text in another tool. Reloading or closing the tab ends it.

All tools