Skip to content

Base64 Encoder & DecoderBeta

Encode and decode text or files as Base64 in your browser. Handles Unicode correctly, plus a URL-safe option and file download.

Direction
Input type
0 characters · 0 lines
When on, uses - and _ instead of + and /, and drops the trailing = padding. Turn this on for use in URLs or filenames.

0 characters · 0 lines

Files are processed only on this device and are never uploaded to a server.

How to use

On the Encode tab, type or paste text and the Base64 string appears right below it. On the Decode tab, paste a Base64 string or a data: URL and it turns back into the original text. There’s no button to press — the result updates as you type, and you can copy it with the button next to it.

Why not just use btoa?

The browser’s built-in btoa function throws an error on any character outside the Latin-1 range (code points 0–255). That means encoding a string containing Korean, Chinese characters or emoji with btoa directly fails or produces garbled output. This tool converts the string to UTF-8 bytes with TextEncoder first and Base64-encodes those bytes, so text in any language is handled safely. Decoding works the same way in reverse, using TextDecoder to turn the bytes back into characters.

URL-safe Base64

Standard Base64 uses three characters — +, / and = — that can carry special meaning inside a URL’s query string or on a filesystem. Turning on the URL-safe option replaces + with - and / with _, and drops the trailing = padding entirely. This variant is commonly used for values such as JWTs (JSON Web Tokens) or URL query parameters. When decoding, make sure you select the same option you used when encoding, or the characters won’t be interpreted correctly.

Files: to Base64 and back

Switch the input type to “File” on the Encode tab to drag a file in or pick one (up to 10MB). The result is a data URL that carries the file’s type, such as data:image/png;base64,iVBORw0KG..., which you can use directly in an image tag or a CSS background. Going the other way, paste a data URL or a plain Base64 string into the Decode tab and use the download button to save it back as a file. If no file type information is available, it downloads with a .bin extension.

Common errors and what they mean

If the input contains a character that isn’t valid Base64 (whitespace and line breaks are ignored automatically), the tool tells you which one. If the length isn’t a multiple of 4 or the = padding is in the wrong place, you’ll see a padding error. Trying to decode standard Base64 with the URL-safe option on (or vice versa) also produces an error — make sure the option matches what was used to encode it.

Privacy

Your text and files are processed entirely inside this browser and are never sent to a server. Everything disappears when you close the page.

Sources

Frequently asked questions

Does encoding Korean, emoji or other non-Latin text break anything?

No. This tool converts characters to UTF-8 bytes first (using TextEncoder/TextDecoder) and then Base64-encodes those bytes. JavaScript's built-in btoa function only supports Latin-1 characters and throws an error on Korean text or emoji, but this tool avoids that problem entirely.

When should I use URL-safe Base64?

Standard Base64 uses the characters +, / and =, which can have special meaning inside URLs or filenames. Turning on the URL-safe option replaces + with - and / with _, and drops the trailing = padding, so the result is safe to use directly in an address bar, a query string or a filename.

Why do I get an "isn't valid UTF-8" error when decoding?

If the original data behind the Base64 string is binary, such as an image or a PDF, rather than text, the decoded bytes can't be interpreted as text and this error appears. You can switch to the hex view to inspect the raw bytes, or use the download button to save them back as the original file.

What format do I get when I convert a file to Base64?

Dropping a file produces a data URL in the form data:<file type>;base64,<data>. This format is commonly used to embed a file directly in an HTML img tag or a CSS rule, and you can copy it as-is.