Base64 Encode and Decode

Encode text or files to Base64, decode Base64 back to text, images or files, and make data URLs for HTML and CSS. Free, runs in your browser, nothing uploaded.

Runs in your browser. Your files are never uploaded. How it works

Base64 Encode and Decode converts text to Base64 and back, decodes Base64 strings and data URLs into images or files, and turns any file up to 20 MB into Base64 or a data URL for HTML and CSS. Text is handled as UTF-8, so every language and emoji works. Everything happens in your browser.

How to use it

  1. Choose a mode: Encode text, Decode or File or image to Base64.
  2. Encode text: type or paste text. Tick URL-safe for URLs and tokens, or Wrap lines at 76 characters (MIME) for email.
  3. Decode: paste Base64 or a full data: URL. Text appears as text; images are previewed; other files can be downloaded.
  4. File or image: choose a file. Leave As a data URL ticked to get a string ready for src or url(), or untick it for plain Base64.
  5. Click Copy or Download. Use result as input feeds the result back in, for example to decode what you just encoded.

The three modes

Mode Input Output
Encode text Any text Base64, standard or URL-safe
Decode Base64 or a data: URL Text, an image preview or a file
File or image to Base64 A file up to 20 MB Base64 or a data URL

Decoding files

When you decode, the tool looks at the first bytes of the result to see what it is. It recognises PNG, JPEG, GIF and WebP images, PDF documents, ZIP archives, gzip data and WOFF, WOFF2 and TTF fonts. Images are shown as a preview and every recognised file can be downloaded with the right extension. If the data is text, it is shown as UTF-8 text. That makes it quick to check what an unknown Base64 string in a log, an email source or an API response really contains.

Images in HTML and CSS

A data URL puts a small image straight into your code, so the browser needs no extra request:

<img src="data:image/png;base64,iVBORw0KGgo..." alt="Logo">
.icon { background-image: url("data:image/svg+xml;base64,PHN2Zy..."); }

This suits small icons, logos in email templates and single-file demos. For large photos it is a poor trade: Base64 is about a third bigger, and the image can no longer be cached on its own. Shrink images first with Compress Image or Resize Image.

Standard, URL-safe and MIME

  • Standard Base64 uses +, / and = padding. It is what most APIs and libraries expect.
  • URL-safe Base64 swaps + and / for - and _ and drops the padding, so the text works in URLs, cookies and file names. JSON Web Tokens use this form.
  • MIME line wrapping breaks the output every 76 characters, as email attachments do.

Tips

  • Reading a JSON Web Token: the middle part between the two dots is URL-safe Base64. Paste it into Decode to read the claims, then view them neatly in the JSON Formatter.
  • Spaces and line breaks in pasted Base64 are fine; they are ignored when decoding.
  • Base64 is not a secret. Never treat encoded text as protected. For real secrets, start with a strong password from the Password Generator.

Private by design

Text and files are encoded and decoded on your own device and never uploaded. See how it works.

Frequently asked questions

What is Base64?

Base64 writes any data, including images and other binary files, using only 64 safe characters: A–Z, a–z, 0–9, + and /. It is used to put files into email, JSON, HTML and CSS, which only carry text. The encoded result is about a third bigger than the original.

Is Base64 encryption?

No. Anyone can decode Base64 in a second, so it hides nothing. Use it to carry data, never to protect passwords or secrets.

What is URL-safe Base64?

A variant that uses - and _ instead of + and /, and leaves out the = padding, so the result can go into a URL or a file name without escaping. JSON Web Tokens use it. Tick URL-safe when encoding; decoding accepts both variants.

Can I decode Base64 to an image or a file?

Yes. Paste the Base64 text or a whole data: URL into Decode. The tool recognises images, PDFs, ZIP archives and fonts from their first bytes, shows a preview of images and offers the file for download. Anything else is shown as text.

Do non-English characters work?

Yes. Text is encoded as UTF-8, so accents, Chinese, Arabic and emojis all survive the round trip and decode back exactly.

Is my data uploaded?

No. Encoding and decoding run in your browser. Text and files are never sent anywhere, which matters for tokens, keys and private documents.

More ways to use Base64 Encode and Decode

Related tools