Base64 Encode & Decode

Type text and the Base64 version appears as you type, or encode a file, optionally as a data: URI. Paste Base64, Base64URL or a data URI to decode it; binary results such as images are previewed and offered as a download.

Loading Base64 Encode & Decode…

How to Use Base64 Encode & Decode

1

Choose encode or decode

Pick the mode at the top of the panel. In encode mode the Base64 output updates as you type.

2

Enter text or pick a file

Type or paste text, or use Encode a file to convert an image, PDF or any other file. File output can be produced as a data: URI ready for HTML or CSS.

3

Decode Base64, Base64URL or data URIs

Paste an encoded string in decode mode. Text results are shown as UTF-8, and binary results such as images are previewed and offered as a download.

4

Copy the result

Use the copy button next to the output. Clear resets the panel when you want to start again.

Base64 Encode & Decode Guide

What Base64 is for

Base64 turns arbitrary bytes into 64 safe characters (A–Z, a–z, 0–9, + and /), so binary or special-character data can travel through systems that only expect plain text. You will see it in HTTP Basic authentication headers, data: URLs for images, email attachments, Kubernetes secrets, and the three parts of a JWT.

Base64 is an encoding, not encryption. Anyone can decode it, so never treat a Base64 value as hidden. It also makes data about a third larger: every three bytes become four characters, with = padding at the end when the input length is not a multiple of three.

Why UTF-8 handling matters

The browser's built-in btoa() only accepts characters in the Latin-1 range, so encoding "café" or "日本" directly throws an error, and naive workarounds produce strings other systems decode as garbage. This tool encodes text as UTF-8 bytes first, which is what servers, command-line tools such as base64 on Linux and macOS, and most programming languages expect.

Base64 vs Base64URL

Base64URL is a variant that swaps + for - and / for _, and usually drops the = padding, so the result can sit in a URL or file name without escaping. JWTs use Base64URL. If a decoder rejects a string full of - and _ characters, it is probably Base64URL: replace them with + and /, add = until the length is a multiple of four, and decode again.

Frequently Asked Questions

Why does my decoded text show strange characters?

The original was probably not UTF-8 text. It may be binary data such as a compressed file or an image, or text in another encoding like Windows-1252. If the output looks like random symbols, try saving it as a file instead of reading it as text.

How much larger does Base64 make a file?

About 33 percent. Every three input bytes become four output characters, plus up to two = padding characters. A 300 KB image becomes roughly 400 KB of Base64, which is why large images should usually be served as files rather than inlined as data URIs.

Can I Base64-encode a password to protect it?

No. Base64 is reversible by anyone without a key, so it offers no protection. HTTP Basic authentication uses Base64 only to make the username and password safe to put in a header, which is why it must always be sent over HTTPS.

What does "Invalid character" mean when decoding?

The input contains something outside the Base64 alphabet, often a space, a line break from an email client, or the - and _ characters used by Base64URL. Remove stray whitespace, and if you see - or _, the value is Base64URL, which this tool also accepts.

Related Guides

More in Developer Utilities