Skip to content

Base64 encoder and decoder

Decode Base64 to text, an image or a file, or encode text and files to Base64, URL-safe if you need it. Nothing you paste or open leaves your browser.

  • Runs in your browser
  • Nothing is uploaded
  • Free, no sign-up
Or turn an image or any file up to 30 MB into Base64.

How it works

To encode, type or paste text, and its Base64 appears as you type. Text is turned into UTF-8 bytes first, the way programming languages and other tools read it, so accented letters, other scripts and emoji come out right. Or choose a file to turn an image, PDF or any file into Base64: plain, as a data URI, or for images as an HTML image tag or a CSS background.

For URL-safe Base64 (also called base64url, used in links, file names and JSON Web Tokens), tick URL-safe: it uses - and _ in place of + and /. Untick Padding to leave off the = at the end. Line breaks every 64 characters match PEM keys and certificates, and every 76 match email (MIME).

To decode, choose Decode and paste the Base64, or open a text file holding it. Both alphabets are read, and spaces, line breaks, missing padding, a data:…;base64, prefix and %2B, %2F and %3D from web addresses are all fine. A character that isn't Base64 is named with its position, and Show where selects it. The result is shown as text when it is text (Base64 to text), as a preview when it is an image (Base64 to image), and otherwise named by its first bytes, such as a PDF, ZIP or MP3, so Download saves it as the right kind of file.

Questions

What is Base64, and is it encryption?

Base64 writes any data, a picture or a PDF as much as text, using only 64 safe characters: A to Z, a to z, 0 to 9, + and /. It lets binary data travel through things made for text, such as JSON, email, HTML and web addresses, at the cost of being about a third bigger. It is not encryption: anyone can decode it, so a password or token in Base64 is as exposed as the plain text.

How do I convert Base64 to an image or a PDF?

Choose Decode and paste the Base64, with or without the data: part in front. The page recognises what the decoded bytes are from their first bytes: an image is shown as a preview, and Download saves it with the right extension, such as .png, .jpg or .pdf. Data that isn't a known file type downloads as .bin, with its first bytes shown in hex.

How do I convert an image to Base64?

Choose Encode, then Choose a file and pick the image (up to 30 MB). The page writes it out as plain Base64, or as a data URI, an HTML image tag or a CSS background you can paste straight into a page. Copy puts it on the clipboard and Download saves it as a .txt file. Any other file, a PDF or a font, works the same way.

Is it safe to decode Base64 online?

On this page, yes: encoding and decoding happen in your browser and nothing you type, paste or open is sent anywhere, saved, or put in the page address. That matters because Base64 often holds API keys, tokens, passwords and private files. Once the page has loaded you can turn Wi-Fi off and it keeps working.

Limits

Files up to 30 MB can be encoded, and Base64 up to 45,000,000 characters (about 30 MB of data) decoded. Results longer than 200,000 characters are cut short in the box, but Copy and Download give all of it. Very large files can make a phone slow while they are worked on.

Decoded text is read as UTF-8. Text in an older character set, such as Windows-1252, shows as binary data with its first bytes in hex; download it and open it in a text editor that lets you pick the encoding. An image shows a preview only if your browser can display that format: HEIC photos, for example, download but don't preview outside Safari.

Base64 isn't encryption or compression. To keep something secret, encrypt it; to make it smaller, compress it before encoding.

Privacy

This tool runs entirely in your browser. The files you open and what you type are never sent to a server, and nothing is stored after you close the page. See the privacy page.

Related tools