How to Encode and Decode Base64

Understand what Base64 is, when to use it, and how to encode or decode text and files — including URL-safe Base64 — entirely in your browser.

Updated 4 min read By CodingEagles
Free tool Base64 Encode / Decode Encode and decode Base64 for text and files (URL-safe option). Open tool

Base64 turns arbitrary bytes into a string of 64 safe ASCII characters. It’s how binary data — images, keys, file contents — travels through systems that only handle text, like JSON, email headers and data URLs.

This guide explains what Base64 is for and how to encode or decode it for both text and files.

TL;DR — Use the Base64 encoder/decoder, switch between Encode and Decode, and turn on URL-safe output when the result goes into a URL. It all runs in your browser.

What Base64 is (and isn’t)

Base64 represents every 3 bytes of input as 4 ASCII characters drawn from A–Z, a–z, 0–9, + and /, with = padding at the end. That’s a roughly 33% size increase — the trade-off for being text-safe.

It is encoding, not encryption. Anyone can decode a Base64 string in a millisecond. Never use it to hide passwords or tokens; it only makes binary data safe to transport as text.

Encoding text

Type or paste your text and switch to Encode. The tool encodes the text as UTF-8 first, so accented characters and emoji survive the round-trip. The output is your Base64 string, ready to drop into JSON, a data URL, or an HTTP header.

Encoding files

Base64 isn’t just for text. Upload a file and its raw bytes are encoded — useful for embedding a small image as a data URL, or inlining a key. When decoding, you can download the bytes back to a real file, so the round-trip is lossless.

URL-safe Base64

Standard Base64 uses + and /, which have special meaning in URLs, plus = padding that often needs escaping. URL-safe Base64 swaps those for - and _ and drops the padding, so the string can sit directly in a path, query parameter or filename. JWTs, for example, use exactly this variant.

Decode anything

Paste a Base64 string, switch to Decode, and get the original text or bytes back. If decoding fails, check for stray whitespace, a wrong character set, or missing padding — the tool flags malformed input so you can fix it fast.

Everything happens locally in the Base64 tool — your data is never uploaded.

Frequently asked questions

Is Base64 encryption?
No. Base64 is encoding, not encryption — anyone can decode it instantly. It hides nothing. Use it to safely represent binary data as text, never to protect secrets.
When should I use URL-safe Base64?
When the encoded string goes into a URL, query parameter or filename. URL-safe Base64 replaces "+" and "/" with "-" and "_" and drops padding, so it survives without escaping.
Why is my decoded text garbled?
Usually a character-set mismatch. This tool encodes text as UTF-8 before Base64, so make sure the original was UTF-8 too. Whitespace or a missing padding "=" can also break decoding.

Ready to try it?

Encode and decode Base64 for text and files (URL-safe option). Free, in-browser, and 100% private — your data never leaves your device.

Open the Base64 Encode / Decode