MockFoxAdvertise

Base64 Encode & Decode

Updated Free mock REST & WebSocket APIs

Convert text to Base64 and back — emoji and accented characters included — or turn any file into a Base64 data URI. Everything happens in your browser.

36 → 56 characters

🔒 Encoded and decoded in your browser — text and files never leave your device.

How to encode or decode Base64

  1. Choose Encode or Decode — or File → Base64 to convert a file.
  2. Paste your text; the result updates as you type. Tick URL-safe for Base64URL output.
  3. Copy the result, or press Swap to reverse the conversion.

How Base64 works

Base64 takes 3 bytes (24 bits) at a time and writes them as 4 characters from a 64-character alphabet: A–Z, a–z, 0–9, + and /. When the input isn't a multiple of 3 bytes, = padding fills the last group. The output is always about 33% larger than the input. It's an encoding for moving binary data through text-only channels — email, JSON, HTML — not encryption: anyone can decode it.

Base64 vs. Base64URL

Standard Base64 uses + and /, which have special meanings in URLs. The URL-safe variant (RFC 4648 §5) swaps them for - and _ and usually drops the = padding, so the value can sit in a URL, a file name or a JWT without escaping. The decoder above accepts both forms, with or without padding.

Why btoa() breaks on emoji

JavaScript's built-in btoa() only accepts characters up to U+00FF: emoji throw an InvalidCharacterError, and accented letters are encoded as Latin-1 instead of UTF-8, so other systems decode them wrongly. Convert to UTF-8 bytes first:

const b64 = btoa(String.fromCharCode(...new TextEncoder().encode(text)));
const text = new TextDecoder().decode(Uint8Array.from(atob(b64), (c) => c.charCodeAt(0)));

Related tools

Frequently asked questions

Is my text or file sent to a server?

No. This tool runs entirely in your browser with JavaScript, so your text or file never leaves your device and isn't logged or stored. You can even use it offline once the page has loaded.

Is Base64 a form of encryption?

No. Base64 is reversible by anyone without a key. Use it to transport data, never to hide it.

Why does decoding say the result isn't valid UTF-8 text?

The Base64 contains binary data — an image, a compressed file or ciphertext — rather than text. The bytes decoded correctly; they just can't be shown as characters.

When should I use a data URI?

For small assets such as icons under roughly 10 KB, where saving an HTTP request matters. Larger files are better served as separate files the browser can cache.

Your business here? Sponsor this tool from $16/week. See placements