What Base64 is for
Base64 represents any bytes using 64 safe characters (A–Z, a–z, 0–9, + and /), so binary data can travel through systems that only handle text: JSON fields, email, HTTP headers, data URLs. Every 3 bytes become 4 characters, so Base64 is about a third larger than the original.
Base64 is an encoding, not encryption. Anyone can decode it, so it hides nothing.
How to use the Base64 Encoder / Decoder
- Choose Encode or Decode.
- To encode, type or paste text, or choose or drop a file. To decode, paste Base64 or a
data:URL. - For encoding, choose URL-safe and padding to match what the receiving system expects.
- Copy the result. Decoded images are previewed, and decoded files can be downloaded.
Examples
Encode text
Hello, World!SGVsbG8sIFdvcmxkIQ==13 bytes don't divide evenly into groups of 3, so the output ends with == padding.
Encode text with accents and emoji
café ☕Y2Fmw6kg4piVThe text is encoded as UTF-8 first: é is 2 bytes and ☕ 3. In JavaScript, btoa("café ☕") throws an error.
URL-safe Base64 without padding
<<???>>PDw_Pz8-PgStandard Base64 would be PDw/Pz8+Pg==. The URL-safe form can go in a URL or file name without escaping.
Decode a JWT header
eyJhbGciOiJIUzI1NiJ9{"alg":"HS256"}JWT parts are URL-safe Base64 without padding; the decoder accepts them as they are. To read a whole token, use the JWT Decoder.
Text, UTF-8 and btoa
Base64 encodes bytes, so text must first be turned into bytes. This tool uses UTF-8, the encoding used almost everywhere on the web. JavaScript's btoa() doesn't: it only accepts characters up to ÿ and throws an InvalidCharacterError for anything else, including emoji. In code, encode with TextEncoder first, or use Uint8Array.prototype.toBase64() where it's available.
URL-safe Base64
+ and / have special meanings in URLs and file names, so URL-safe Base64 (RFC 4648 §5, also called base64url) uses - and _ instead, and usually drops the = padding. JWTs use it. When decoding, this tool accepts both alphabets, with or without padding.
Files and images
Choose or drop a file to encode it; turn on Data URL to get a data:image/png;base64,… URL you can use in HTML or CSS. When decoding, the tool recognises common file types (PNG, JPEG, GIF, WebP, SVG, PDF, ZIP and others) from their first bytes, shows images as a preview, and lets you download the file.
Options
- Encode / Decode
- Encode turns text or a file into Base64; Decode turns Base64 back into text or a file.
- URL-safe
- Encode with
-and_instead of+and/, for URLs, file names, cookies and JWTs. - Padding (=)
- Keep the
=characters that make the length a multiple of 4. Most decoders need them; URL-safe Base64 usually omits them. - Data URL
- For files: prefix the Base64 with
data:<type>;base64,so it can be used directly in animgtag, CSS or JSON.
Limitations
- Files up to 10 MB can be encoded. Base64 is a third larger than the file, so large files are better sent as files.
- Text is decoded as UTF-8. Data that isn't valid UTF-8 is treated as a binary file.
- File types are detected from their first bytes; unrecognised types are offered as a download without an extension.
Frequently asked questions
Is my data uploaded?
No. Encoding and decoding happen in your browser, including files. Nothing you paste or choose is sent anywhere.
Is Base64 encryption?
No. Base64 is a reversible encoding that anyone can decode. Never use it to hide passwords or secrets.
Why does btoa fail with InvalidCharacterError?
btoa only accepts characters with codes up to 255. Encode the text as UTF-8 bytes first, for example with TextEncoder, then Base64-encode the bytes, as this tool does.
How do I decode a Base64 image?
Switch to Decode and paste the Base64 or the whole data:image/…;base64, URL. The tool detects the image type, shows a preview and lets you download it.
What does the = at the end mean?
It's padding: Base64 encodes 3 bytes as 4 characters, and = fills the last group when the data isn't a multiple of 3 bytes long. One = means the last group had 2 bytes, two mean 1 byte.