Free tool

Base64 Encode and Decode

Turn text or a file into Base64, and turn Base64 back into readable text or a download. The translation happens on your device, not on a server.

  • Private: nothing uploaded
  • Free
  • No sign-up

Runs in your browser. Your files never leave your device.

Type something to see the Base64.

Base64

How to use it

  1. Pick Text, File to Base64 or Base64 to file at the top.

  2. For text, type or paste it and choose whether you want the URL safe version.

  3. Copy the result or download it as a .txt file. The output updates as you type.

  4. To recover a file, paste the data URL or Base64, give the file a name and press Download the file.

About this tool

Base64 is a way of writing bytes using only letters, digits and two symbols. It exists because many systems that carry text cannot carry raw binary: email, JSON, web addresses and data URLs are all text channels. This page encodes and decodes Base64 in your browser, including non English text and files up to 10 MB, without sending anything to a server.

What Base64 is actually for

A small image can be placed directly in a web page as a data URL, which saves a request. A signature or a PDF can be sent inside a JSON body as Base64. Email attachments are Base64 inside the message. In each case the point is the same: turn bytes into characters that every text system can pass along unchanged. Base64 is also used in configuration files and in some API keys, where a long random byte string has to be pasted as text.

Why UTF-8 matters

The old browser function for Base64 only accepts one byte per character. Feed it an emoji, Urdu script or Arabic text and it either throws an error or produces broken output. This tool first turns the text into UTF-8 bytes and then encodes those bytes, which is the correct order. Decoding does the reverse and checks that the bytes really are valid text. If the Base64 came from an image, a PDF or a zip file, the bytes are not text, and the tool says so instead of showing a page of symbols.

URL safe Base64, and the padding

Standard Base64 uses a plus sign and a slash, and it ends with one or two equals signs to fill the last group. Those three characters need escaping in a web address, so a URL safe variant replaces plus with a hyphen, slash with an underscore and drops the padding. The result can sit in a query string or a file name without extra encoding. Some systems insist on the padding, so keep the standard version if a service rejects the URL safe one. Decoding here accepts both forms, with or without padding.

Data URLs and the 10 MB limit

A data URL has the form data: followed by the file type, then base64, a comma and the encoded bytes. It is a complete file in one line of text, which is why a browser can show it as an image. Base64 uses four characters for every three bytes, so the text is about a third larger than the file. That is also why the file mode stops at 10 MB: a much larger file would produce a text line that some browsers struggle to hold in a text box. On the way back, the tool reads the file type from the data URL and names the download with a matching extension when the name has none.

Base64 is not encryption

Anyone can decode Base64 in a second, with no key and no password. It hides nothing, it only changes the alphabet. Do not use it to protect a password, a card number or a private note. If the data needs to stay secret, it needs real encryption before it is encoded, and the key has to be kept somewhere else. What this tool does offer is privacy from servers: the text or file is processed in the page, so there is no copy on a website. For related work, the QR code generator encodes text for scanning, and the JSON to CSV converter handles tabular data.

Questions

More text and code tools