Free Base64 Encoder & Decoder Online

Encode text or files to Base64, decode Base64 back to text or files, switch to Base64URL, add or remove padding, validate input, and download results. Everything runs locally in your browser.

Text

0 bytes

Output

0 chars

Tip: Ctrl/Cmd + K focuses the input. Ctrl/Cmd + Enter repeats last action.

Advertisement

Files

File → Base64

Drop a file here to encode it

Base64 → File

Understands raw Base64 or data:[mime];base64,....

Release update v1.1

v1.1 (June 6, 2026)

  • Added practical Base64 examples, code snippets, Base64URL comparison, and troubleshooting guidance.
  • Added live mode, swap input/output, line wrapping, charset selection, and data URL output.
  • Improved decode handling with automatic Base64URL detection, missing-padding notices, and data URL parsing.
  • Added drag-and-drop file encoding plus richer previews for decoded images, audio, video, PDFs, and text files.

How to use this Base64 encoder and decoder

  1. Paste text or Base64 into the input box.
  2. Choose Encode or Decode. Use URL-safe mode for Base64URL strings used in JWTs, URLs, and filenames.
  3. Adjust padding if your target system requires or omits trailing = characters.
  4. Copy the result or use the file tools to encode a file to Base64 or decode Base64 back into a downloadable file.

Base64 examples

Input Base64 output Notes
Hello SGVsbG8= Plain UTF-8 text
Hello world SGVsbG8gd29ybGQ= Spaces are encoded too
Binary file data:image/png;base64,... Used in data URLs

Base64 vs Base64URL

Standard Base64 and Base64URL encode the same bytes, but they use different characters for URL and filename safety.

Feature Standard Base64 Base64URL
Character 62 + -
Character 63 / _
Padding Usually uses = Often omits =
Common uses Email, MIME, APIs, data URLs JWTs, OAuth tokens, URLs, filenames

Base64 code examples

JavaScript browser

const encoded = btoa("Hello");
const decoded = atob(encoded);

JavaScript UTF-8 safe

const bytes = new TextEncoder().encode("Hello 👋");
const base64 = btoa(String.fromCharCode(...bytes));

Node.js

const encoded = Buffer.from("Hello", "utf8").toString("base64");
const decoded = Buffer.from(encoded, "base64").toString("utf8");

Python

import base64

encoded = base64.b64encode("Hello".encode()).decode()
decoded = base64.b64decode(encoded).decode()

Command line

echo -n "Hello" | base64
echo "SGVsbG8=" | base64 --decode

Base64 troubleshooting

Invalid characters

Standard Base64 uses letters, numbers, +, /, and sometimes =. If your string contains - or _, enable URL-safe mode.

Missing padding

Some systems remove trailing = characters. If decoding fails, try adding padding until the Base64 length is a multiple of 4.

Decoded text looks broken

The Base64 may represent binary data such as an image, PDF, ZIP, or certificate rather than text. Use the Base64-to-file option instead of reading it as UTF-8 text.

Data URL will not decode

A data URL starts with a prefix such as data:image/png;base64,. This tool accepts data URLs, but the actual Base64 payload begins after the comma.

FAQs: Base64 Encoder & Decoder

What is Base64 used for?

Base64 is an encoding that turns arbitrary binary data into ASCII text. It’s commonly used in email (MIME), data URLs (e.g., embedding small images), JSON/API payloads, and anywhere binary needs to travel over text-only channels.

What is URL-safe Base64?

URL-safe Base64 follows RFC 4648: it replaces + with - and / with _ so the string can appear in URLs and filenames without escaping. Some systems also drop the trailing = padding.

Does this tool upload my data?

No. All encoding/decoding happens locally in your browser. If you use file features, files are processed in-memory; nothing is sent to a server.

Why do some Base64 strings end with =?

= characters are padding so the output length is a multiple of 4 characters. Many parsers accept unpadded Base64, but some require padding. Turn off “Include padding =” only if your target system allows unpadded Base64.

What’s the difference between encoding and encryption?

Encoding (Base64) is reversible and not a security measure—it just re-formats data. Encryption protects data and requires keys. Don’t use Base64 for secrecy.

Can I use this with non-Latin text or emojis?

Yes. The tool uses UTF-8 via TextEncoder/TextDecoder, so Unicode text (e.g., emojis, CJK) round-trips correctly.

How do I convert files?

Use the file picker. “File → Base64” produces the Base64 payload (suitable for data URIs or JSON). To recover a file, paste its Base64, then click “Base64 → File” to download.

Why does my Base64 contain line breaks?

Some legacy encoders wrap lines at 76 characters (MIME). This tool doesn’t insert line breaks. If your input has them, it will still decode successfully.

What’s the maximum size I can convert?

There’s no fixed limit, but browser memory is finite. Very large files (hundreds of MB) may be slow or fail. For huge data, prefer streaming or server-side tooling.

How do I make a data URL from Base64?

Prepend the MIME type and the base64 flag, e.g. data:image/png;base64,AAAA…. You can get the MIME type from the selected file when using the file encoder.

Why does validation say “invalid characters”?

Strict mode rejects characters outside the Base64 alphabet. Enable “URL-safe” if your input uses - and _, or disable strict validation to attempt a best-effort decode.

5 Fun Facts about Base64

Made for email

Base64 landed in the early ’90s for MIME email so binary attachments could survive 7-bit mail relays without mangling.

Origins

3 bytes → 4 chars

Each 24-bit chunk splits into four 6-bit values. Those map to 64 symbols; padding just fills the final quartet.

Encoding math

URL-safe swaps two signs

RFC 4648 replaces +// with -/_ so Base64 can live in URLs and filenames without escaping.

Transport trick

Not a lock

Base64 is reversible formatting, not security. Anyone can decode it with one line—use real encryption for secrecy.

Misconception

Data URLs bundle type

data: URLs store the MIME type plus Base64 so tiny images or fonts ride inside HTML/CSS with zero extra requests.

Bundling

Explore more tools