Base64 Encoder & Decoder
Convert text and files to Base64 and back. Handles Unicode correctly, supports URL-safe base64url, and tells you exactly why invalid input fails.
Runs in your browserNo sign-upNothing uploaded
How to use the Base64 Encode / Decode
- Choose Encode or Decode.
- Type or paste your input. The result updates as you type.
- For URLs, JWTs and filenames, tick URL-safe to use
-and_, and optionally drop the=padding. - To embed an image or font, click Encode file and keep Output as data URI checked.
- Copy the result, or use Swap to feed it back in the other direction.
How Base64 works
Base64 represents binary data using 64 printable ASCII characters: A-Z, a-z, 0-9, + and /. Every 3 bytes of input become 4 characters, so encoded data is about 33% larger. When the input length is not a multiple of 3, one or two = signs pad the output. Base64 is an encoding, not encryption: anyone can decode it.
Standard Base64 vs. base64url
The + and / characters have special meaning in URLs and file paths. The URL-safe alphabet from RFC 4648 §5 replaces them with - and _ and usually omits padding. JWTs, many OAuth parameters and some cloud APIs use base64url. The decoder here accepts both alphabets automatically.
Unicode and the btoa() pitfall
In browsers, btoa("café") works but btoa("日本") throws, because btoa only accepts Latin-1. The correct approach is to encode the text to UTF-8 bytes first, which this tool does. In JavaScript: btoa(String.fromCharCode(...new TextEncoder().encode(text))), or Buffer.from(text).toString('base64') in Node.js.
Common uses
- Data URIs for small images and fonts in CSS or HTML
- HTTP Basic authentication headers (
user:passwordencoded) - Binary attachments in JSON payloads and email (MIME)
- Kubernetes Secrets, which store values as Base64