DailyDeskTools home

Base64 Encoder and Decoder

Encode and decode Base64 text with UTF-8 support, and turn files or images into data URLs.

  • Free forever
  • No signup
  • Runs on your device
Base64 Encoder and DecoderRuns locally · nothing uploaded
Loading tool…

How to use the Base64 Encoder and Decoder

  1. 1Choose Encode text, Decode, or File to Base64.
  2. 2Type or paste your text, or drop in a file.
  3. 3Turn on URL-safe output if the result will go in a URL or token.
  4. 4Copy the result or download it as a file.

What Base64 is

Base64 turns any data into plain text using 64 safe characters: A–Z, a–z, 0–9, + and /. It lets binary data travel through systems that only handle text, such as email, JSON and HTML.

Base64 is an encoding, not encryption. Anyone can decode it, so never use it to hide passwords or secrets.

Text, emoji and other languages

Browsers' built-in btoa function fails on characters outside basic Latin. This tool converts text to UTF-8 bytes first, so accented letters, non-Latin scripts and emoji encode and decode correctly.

URL-safe Base64

Standard Base64 uses + and /, which have special meanings in URLs. The URL-safe variant (Base64URL) replaces them with - and _ and drops the = padding. It is used in JSON Web Tokens and many APIs. The decoder accepts both forms.

Files and data URLs

A data URL embeds a file directly in HTML or CSS, for example data:image/png;base64,iVBOR.... It is handy for small icons and email images. Base64 makes data about a third larger, so keep data URLs for small files.

A worked example

The text Hello, world! is 13 bytes. Base64 reads bytes in groups of three and writes each group as four characters, so it becomes SGVsbG8sIHdvcmxkIQ==. The two = signs are padding: they fill the last group out to four characters. café is five bytes in UTF-8 (the é takes two), so it encodes to Y2Fmw6k=.

The same bytes can look different in the URL-safe form. The two bytes FB FF are +/8= in standard Base64 and -_8 in Base64URL. The format is defined in RFC 4648.

Decoding a Base64 image

To turn a Base64 string back into a picture, paste it into Decode. A leading data:image/png;base64, prefix is removed for you, and line breaks are ignored. Because the result is binary, the tool offers it as a download. Save it and give it the right extension (.png, .jpg, .pdf) so your computer opens it correctly.

Base64 in code

// Browser: UTF-8 safe
const b64 = btoa(String.fromCharCode(...new TextEncoder().encode("café")));
import base64
base64.b64encode("café".encode("utf-8"))   # b'Y2Fmw6k='
base64.urlsafe_b64decode("-_8=")           # b'\xfb\xff'
echo -n "Hello, world!" | base64

When decoding fails

Symptom Likely cause
Invalid character error The string contains characters outside the Base64 alphabet, such as a stray quote or a %2B that was never URL-decoded. Run it through the URL encoder and decoder first.
Garbled text after decoding The original was not UTF-8 text, or it was Base64 of a file.
Length is not a multiple of 4 Padding was stripped. Base64URL does this on purpose.

Base64 is not a checksum. To confirm a download is intact, use the file checksum checker. It is also handy for compact IDs: a 16-byte value from the UUID generator becomes 22 Base64URL characters instead of 36.

Frequently asked questions

Is Base64 secure?

No. Base64 is a reversible encoding that anyone can decode. Use proper encryption to protect sensitive data.

Why is my Base64 longer than the original?

Base64 represents every 3 bytes with 4 characters, so the output is about 33% larger than the input.

What happens if I decode an image?

If the decoded data is not text, the tool tells you and offers it as a file download instead.

Are my files uploaded?

No. Files are read and converted by your browser and never leave your device.

What does the = at the end of Base64 mean?

It is padding. Base64 works in groups of three bytes, and one or two = signs fill the last group when the data does not divide evenly. Base64URL often leaves the padding out.

Can I put a Base64 string in a URL?

Standard Base64 contains + and /, which have special meanings in URLs. Use the URL-safe option, which swaps them for - and _, or percent-encode the string.

Last updated · By the DailyDeskTools team

Built and written with AI assistance, then tested by hand by our team. How we make our tools