Base64 encode and decode
Type text on the left to get Base64 on the right, or paste Base64 on the right to decode it. Works with emoji, URL-safe Base64, files, images and data URIs. Everything runs in your browser.
How to encode and decode Base64
- To encode, type or paste text in the Text box. The Base64 appears on the right as you type.
- To decode, paste Base64 in the Base64 box. The text appears on the left. If the data is an image, a PDF or other binary file, you get its type, a preview and a Download button instead.
- For files, press Encode a file or drop one on the tool, then copy the Base64 or a ready-to-use
data:URI.
What is Base64?
Base64 turns any bytes into text made of 64 safe characters: A–Z, a–z, 0–9, + and /, with = as padding at the end. Every 3 bytes become 4 characters, so Base64 is about 33% bigger than the original. It is used to put binary data where only text fits: email attachments (MIME), data URIs in HTML and CSS, JSON APIs, HTTP Basic auth headers, Kubernetes secrets and JWTs.
Base64 is not encryption. Anyone can decode it, so never use it to hide passwords or secrets.
Standard vs URL-safe Base64 (Base64url)
Standard Base64 uses + and /, which have special meanings in URLs and file names. URL-safe Base64 (Base64url, RFC 4648 §5) uses - and _ instead, and usually drops the = padding. JWTs, many web APIs and Python's urlsafe_b64encode use it. The decoder here accepts both, with or without padding, and tells you which one it found.
Base64 and UTF-8
JavaScript's btoa("é") gives a different result from most other languages, and btoa("👋") throws an error, because btoa only handles Latin-1. This tool encodes text as UTF-8 first, which is what Python, Go, Java, PHP, the base64 command and nearly every API expect. To do the same in JavaScript, use new TextEncoder().encode(text) and encode the bytes.
Errors it explains
- Invalid characters such as
!, accents or invisible characters pasted from a web page, with the line and column. - Wrong length: Base64 comes in groups of 4 characters; a group with only 1 character can't be decoded.
- Misplaced padding: data after the
=, or too many=. - Mixed alphabets: both
+ /and- _in the same text, usually from two values pasted together.
Questions
Is my data sent to a server?
No. Encoding and decoding run entirely in your browser. Nothing you type, paste or open is uploaded, so it is safe for tokens, keys and private files.
Is Base64 encryption?
No. Base64 is an encoding, not encryption. Anyone can decode it without a key. Use real encryption to protect secrets.
Why is Base64 bigger than the original?
Every 3 bytes become 4 characters, so Base64 is about 33% larger, plus line breaks if it is wrapped.
What do the = signs at the end mean?
They are padding. Base64 works in groups of 4 characters, and = fills the last group when the data length isn't a multiple of 3. URL-safe Base64 often leaves it out; this decoder accepts both.
What is the difference between Base64 and Base64url?
Base64url replaces + with - and / with _ so the result is safe in URLs and file names, and usually drops the padding. It is used in JWTs and many web APIs.
How do I convert an image to Base64?
Press Encode a file (or drop the image on the tool) and copy the Base64, or press Copy as data URI to get a data:image/png;base64,… string you can use directly in an <img> tag or CSS.
How do I decode Base64 to a file?
Paste the Base64 (or a data URI) in the Base64 box. If it isn't text, the tool detects the file type (PNG, JPEG, PDF, ZIP and more), shows a preview and a hex dump, and gives you a Download button.
Why does btoa fail with emoji or accents?
btoa only accepts characters up to U+00FF. Encode the text as UTF-8 bytes first (TextEncoder), then Base64-encode the bytes. This tool always uses UTF-8.
How big a file can I encode?
Up to 10 MB per file, limited to keep the page responsive. The work happens on your device.