Developer tools

Base64 Encode & Decode

Encode text or files to Base64, or decode Base64 back to text, an image or a file. Handles Sinhala, emoji and every language, offers a URL-safe version, and shows a preview of decoded images. Free, and nothing leaves your browser.

Processed on your device. Your text and files are not uploaded, logged or stored.
Input
Result

How to encode and decode Base64

Choose Encode to turn text or a file into Base64, or Decode to turn Base64 back into its original text or file. The result updates as you type. Use Copy to put it on your clipboard, Download to save it, and Use as input to run the result back through the opposite direction and check that it round-trips.

Encoding text, files and images

  • Text: your text is converted to UTF-8 bytes and then encoded, so Sinhala, Tamil, Chinese, accents and emoji all work.
  • Files: use Open file or drop a file on the input box (up to 20 MB). Tick the data: prefix to get a ready-to-use data URI for HTML or CSS.
  • URL-safe: replaces + and / with - and _ and can drop the = padding, which is what JWTs and many APIs expect.
  • Wrap at 76: breaks the output into the 76-character lines used by email (MIME) and PEM files.

Decoding, and what the messages mean

The decoder is forgiving about harmless things and strict about real mistakes. It accepts line breaks and spaces, the data: prefix, URL-safe characters and missing padding, and tells you what it adjusted. It stops with a clear message when a character is not allowed in Base64 (with its position), when the = sign is in the middle, or when the length cannot be valid because part of the text is missing. If the decoded bytes are not text, the page tells you what kind of file it looks like and offers a download instead of showing garbled characters.

Base64 is encoding, not security

People sometimes see a long string of letters and assume it is encrypted. Base64 is only a different way to write the same bytes. Anything encoded with it can be read by anyone. Use real encryption for secrets, and remember that credentials in a Basic Auth header or in a config file are readable the moment someone decodes them.

How much bigger does Base64 make my data?

Every three bytes become four characters, so the result is about 33% larger than the original, plus a little extra for line breaks if you wrap lines. That is why embedding large images as Base64 in a web page is usually a bad trade, while small icons and inline SVG-sized images can be fine.

Privacy

Everything runs in your browser. The text and files you use are not uploaded, logged or stored, and nothing is kept after you close the tab.

Frequently asked questions

What is Base64 and why is it used?

Base64 is a way of writing any data, including images and files, using only 64 safe text characters: A–Z, a–z, 0–9, + and /. It is used when binary data has to travel through something that only handles text, such as JSON, email, HTML, URLs or an HTTP header. It makes the data about one third bigger.

Is Base64 encryption?

No. Base64 hides nothing. Anyone can decode it in a second, with this page or any other tool. Never use it to protect passwords, keys or personal data. If you see a secret that is only Base64 encoded, treat it as if it were written in plain text.

Does it handle Sinhala, Tamil, emoji and accented letters?

Yes. Text is converted to UTF-8 bytes first and then to Base64, so any language and any emoji round-trip correctly. This is a common place where simple tools and the browser’s plain btoa() function fail with an error. When you decode, the bytes are read back as UTF-8.

What is URL-safe Base64 (Base64url)?

Standard Base64 uses + and /, which have special meanings in URLs. The URL-safe version uses - and _ instead, and often drops the = padding. JWT tokens and many web APIs use it. Tick URL-safe to create it. When you decode, both versions are accepted automatically.

Why does the encoded text end with = or ==?

Base64 works in groups of three bytes. When the data does not fill the last group, one or two = signs are added as padding so the length is a multiple of four. If padding is missing from text you paste, the decoder adds it back and tells you.

Why does decoding show strange symbols or say binary data?

The Base64 was not text to begin with. It may be an image, a PDF, a zip file or encrypted data. The page checks the first bytes to recognise common formats, shows a preview for images, and lets you download the result as a file.

How do I turn an image into Base64 for CSS or HTML?

Use Open file and choose the image, then tick “Add data: prefix”. You get a data URI such as data:image/png;base64,… that you can paste into an img tag or a CSS url(). It works best for very small images, because the text is a third larger than the file.

How do I turn Base64 back into a file?

Choose Decode, paste the Base64 (with or without the data: prefix) and press Download when the page recognises binary data. The file gets a sensible extension such as png, jpg, pdf or zip when the format is recognised.

What does “wrap lines at 76” do?

It breaks the output into lines of 76 characters, the format used by MIME email and PEM files. Leave it off for JSON, URLs and APIs, which expect one unbroken line.

Is my data uploaded?

No. Encoding and decoding happen in your browser, and nothing is sent to a server or stored. You can open large files up to 20 MB.

Is the HTTP Basic Auth header secure because it is Base64?

No. Basic authentication sends username:password as Base64, which anyone can decode. It is only acceptable over HTTPS, and even then a token is the better choice for new work.

Related tools

JSON Formatter JWT Decoder Image to PDF Password Generator All converters