Base64 encode and decode

Encode text to Base64 or decode it back, and convert whole files and images into Base64 or a data URI. You can also turn Base64 back into a downloadable file.

  • Free
  • No sign-up
  • Runs in your browser
base64-encode-decode

100% private — everything is converted in your browser and nothing is uploaded.

Files and images

Encode a file to Base64

100% private — everything is converted in your browser and nothing is uploaded.

How it works

Choose text or a file

Text encodes and decodes in the first box; files and images in the second.

Set the options

URL-safe, line breaks, or a data URI prefix, depending on where you will use it.

Copy or download

Copy the Base64, or download the decoded file.

Binary data as plain text

Base64 is a way of writing any data, including files, images and arbitrary bytes, using only 64 safe characters: letters, digits, plus and slash. That makes it possible to send binary content through channels that only handle text, such as email bodies, JSON documents, URLs, HTML and CSS, configuration files and HTTP headers. It is also how a small image can be embedded directly in a web page as a data URI. Encoding makes the data about a third larger, and it is a format, not encryption: anyone can decode it.

Text, with UTF-8 done right

The first section converts text. Text is first turned into UTF-8 bytes, so accented letters, symbols and emoji encode and decode correctly, which is where quick tools often go wrong. Pasting Base64 and choosing decode gives you back the text. If the decoded data is not valid text, for example because it is an image, the tool says so and points you to the file section.

URL-safe and line-wrapped variants

Standard Base64 uses + and /, which have special meanings in URLs, and ends with = padding. The URL-safe variant replaces them with - and _ and drops the padding, and is used in JSON Web Tokens and in links. The MIME variant breaks the output into lines of 76 characters, as email requires. Decoding accepts all of these forms and ignores spaces and line breaks.

Files and images

The second section encodes a whole file. Choose a file and you get its Base64, optionally with the data: prefix that turns it into a data URI you can paste into an HTML img tag or a CSS url(). Images are previewed, and the size increase is shown. The reverse direction takes Base64 or a data URI, detects the type of file from its first bytes, and lets you download it with a name of your choice, useful for recovering an attachment or an image embedded in a document.

What it does not do

Base64 is not a way to protect data: it hides nothing. Big files make very long strings, and embedding large images as data URIs slows a page down more than referring to a file. Files above 100 MB are not accepted, since everything is processed in memory. For percent-encoding of URLs, use the URL encoder.

Frequently asked questions

How do I encode text to Base64?
Type or paste the text in the first box and keep "Text to Base64" selected. The Base64 appears next to it.
How do I decode Base64?
Choose "Base64 to text" and paste the Base64. If the data is a file rather than text, use the file section to download it.
How do I convert an image to Base64?
Drop the image in the file section. You get its Base64, with the data URI prefix if you leave that option on, ready to use in HTML or CSS.
What is URL-safe Base64?
A variant that uses - and _ instead of + and / and has no = padding, so it can be used in URLs and tokens without escaping.
Is Base64 encryption?
No. It is just an encoding and anyone can reverse it. Do not use it to hide sensitive data.
Are my files uploaded anywhere?
No. Everything is converted in your browser.