Skip to content
epitometool

Base64 encode / decode

Encoders & decoders

Encode and decode Base64 strings in the browser.

Updated

Mode

Plain text

0 chars

Base64

0 chars

  • EnterCopy output
  • KClear input

Quick start

How to use the Base64 tool

Pick a direction, paste your data, copy the result — nothing leaves your browser.

  1. Step 1
    Encode or decode

    Toggle between Encode and Decode. Standard variant is the default; switch to URL-safe for JWT / OAuth / filename use.

  2. Step 2
    Paste input

    Drop text into the left pane. UTF-8 multi-byte characters — accents, CJK, emoji — round-trip cleanly.

  3. Step 3
    Copy output

    Hit Copy or press ⌘/Ctrl+Enter. The output stays available until you clear or close the tab.

In-depth guide

Base64 encoding, decoding, and when to use it

Base64 turns arbitrary bytes into a 64-character ASCII alphabet so they can travel safely through text-only channels — email bodies, JSON, URLs, HTML attributes, environment variables. This tool encodes and decodes both standard and URL-safe Base64 in your browser, with full UTF-8 support.

What Base64 actually does

Base64 takes input three bytes at a time, splits the 24 bits into four 6-bit groups, and maps each group to one of 64 printable characters (A-Z a-z 0-9 + /). The encoded form is always a multiple of 4 chars; = pads the last block when the input isn't a multiple of 3.

The trade-off is size: encoded data is ~33% bigger. The upside is that it survives any channel that strips or rewrites non-printable bytes — which historically was most of email and many APIs.

Standard vs URL-safe

There are two RFC 4648 alphabets you'll encounter:

  • Standard (§4) uses + and / plus = padding. This is what MIME / email, PEM-encoded keys, and most legacy APIs emit.
  • URL-safe (§5) swaps +- and /_, then strips the = padding. This lets the encoded string sit in a URL path, query string, filename or JWT segment without further escaping. JWT, OAuth tokens and many file IDs use this variant.

The decoder accepts either — we normalise the alphabet and re-pad before calling atob.

The UTF-8 pitfall every dev hits

Calling btoa("café") in vanilla JS throws "InvalidCharacterError: The string contains characters outside of the Latin1 range." The native btoa only understands single-byte Latin-1.

Multi-byte UTF-8 characters — emoji, accented Latin, CJK, Arabic, Hebrew — must be converted to bytes first, then Base64-encoded. The browser's TextEncoder handles this:

const bytes = new TextEncoder().encode("café 🚀");
btoa(String.fromCharCode(...bytes));

This tool wraps that wrapper for you, so any Unicode input round-trips losslessly.

Common real-world uses

  • Data URIsdata:image/png;base64,iVBOR… inlines an image into HTML/CSS without a separate request.
  • HTTP Basic Auth — the Authorization: Basic header is base64(username:password).
  • JWT — header, payload and signature are URL-safe Base64-encoded JSON / bytes.
  • API keys / nonces — random bytes from a CSPRNG, encoded for safe transport.
  • Email attachments — MIME wraps binary attachments in 76-column Base64.

Base64 is not encryption

Anyone with the encoded string can recover the original in milliseconds — it's a transport encoding, not a cipher. If you need confidentiality, encrypt first, then Base64-encode the ciphertext.

The most common misuse is treating Base64 as "obfuscation". A secret left in client-side JS as const apiKey = atob("…") is exactly as exposed as the unencoded string. Use real secret-handling primitives (server-side env vars, OAuth, KMS) for anything that needs to stay private.

Frequently asked questions

Does this tool upload my data anywhere?

No. Encoding and decoding happen entirely in your browser using the built-in atob/btoa functions wrapped with TextEncoder/TextDecoder for full UTF-8 support. You can verify in DevTools → Network: zero requests fire during use.

What's the difference between standard and URL-safe Base64?

Standard Base64 (RFC 4648 §4) uses `+`, `/` and `=` padding. URL-safe Base64 (RFC 4648 §5) replaces `+` with `-`, `/` with `_`, and drops the `=` padding — so it can sit in a URL or filename without further escaping. Decode accepts either.

Can I Base64-encode emoji or non-Latin characters?

Yes. We encode the bytes of the UTF-8 representation, so emoji, CJK, RTL scripts and combining marks all round-trip cleanly. The naive `btoa(emoji)` call breaks because it only accepts Latin-1 — we avoid that bug.

Why do I see line breaks every 76 characters in some Base64?

MIME (RFC 2045) requires lines no longer than 76 chars. Email and some PEM-encoded keys use this wrapping. Pick 64 / 76 / 120 from the Wrap dropdown, or leave it as none for a single line.

Is Base64 encryption?

No — it's an encoding, not a cipher. Anyone with the encoded string can recover the original in milliseconds. Use it to transport bytes through text-only channels (email, JSON, URLs). For confidentiality, encrypt the data first and then Base64-encode the ciphertext.

How big does the output get?

Base64 inflates data by 4/3, then pads to a multiple of 4 characters. A 1 MB input becomes ~1.37 MB encoded. URL-safe mode is the same size minus the `=` padding (at most 2 bytes saved).

Can I decode a Base64 image?

If you paste the Base64 portion (without the `data:image/png;base64,` prefix) into Decode mode, this tool returns the raw byte count. For visual preview of an image we'll add a dedicated Image ⇄ Base64 tool soon.

Keep exploring

More tools you'll like

Hand-picked utilities that pair well with the one you're on — all free, client-side, and zero-signup.