Base64 Encode & Decode

Convert text or any file to Base64 and back. Handles UTF-8 (accents, CJK, emoji) correctly and supports the URL-safe alphabet and MIME line wrapping.

Loading tool…

About the Base64 Encode/Decode

Base64 (RFC 4648) represents binary data with 64 printable ASCII characters: A–Z, a–z, 0–9, + and /, with = padding. Every 3 input bytes become 4 output characters, so encoded data is about 33% larger. It is an encoding, not encryption: anyone can decode it.

The browser functions btoa() and atob() only accept Latin-1, so btoa('é') throws or garbles multi-byte text. This tool first converts text to UTF-8 bytes with TextEncoder, so Café ☕ encodes to Q2Fmw6kg4piV exactly as Node's Buffer.from(s).toString('base64') would. The decoder accepts both alphabets, ignores whitespace and tolerates missing padding.

URL-safe (Base64url) swaps +/ for -_ and drops padding, as used in JWTs and URL parameters. MIME wrapping breaks lines at 76 characters as required by RFC 2045 for email bodies. Use Encode a file to turn an image, PDF or certificate into Base64; everything is processed locally and nothing is uploaded.

How to use it

  1. Choose Encode or Decode.
  2. Type or paste your text, or click “Encode a file…” to load a file.
  3. Tick URL-safe or MIME wrapping if your target needs it.
  4. Copy the result, or use ⇄ Swap to reverse the conversion.

Frequently asked questions

Why does btoa() fail with “The string to be encoded contains characters outside of the Latin1 range”?
btoa works on single bytes. Encode the string to UTF-8 first: btoa(String.fromCharCode(...new TextEncoder().encode(s))), or use this tool, which does that for you.
What is the difference between Base64 and Base64url?
Base64url replaces + with - and / with _ so the value is safe in URLs and filenames, and usually omits the = padding. The decoded bytes are identical.
Why does my decoded output say it is not UTF-8 text?
The Base64 contains binary data such as an image or a ZIP file. Click “Download decoded bytes” to save it as a file instead of viewing it as text.
Is Base64 a way to hide passwords?
No. Base64 is reversible by anyone without a key. Use a password hash such as bcrypt for storage and TLS for transport.

Related tools