Base64 decode and encode
Decode Base64 to text or a file, encode text to Base64, or turn an image into a data URI. Unicode text works, and so does URL-safe Base64.
- 100% free
- Runs in your browser
- No uploads
- Runs on your deviceEvery tool works directly in your browser. No files are uploaded.
- Your privacy mattersYour files never leave your device, so there's nothing for us to store.
- No limitsUse any tool as much as you need. No daily caps, no waiting.
- Completely freeNo signup and no trial to cancel. Ads keep the tools free.
How to decode or encode Base64
- Pick what to do. Encode for text, Decode for Base64, or From a file for images and other files.
- Paste or drop your input. Results update as you type. Decode accepts standard or URL-safe Base64, with or without padding, line breaks or a data: prefix.
- Choose the options. URL-safe swaps + and / for - and _. For files, pick a data URI, plain Base64, an HTML img tag or a CSS background line.
- Copy or download. Decoded binary data, such as an image, downloads as a file with the right extension.
How Base64 works
Base64 takes the input 3 bytes (24 bits) at a time and splits them into four 6-bit groups. Each group, a number from 0 to 63, becomes one character from the alphabet A-Z a-z 0-9 + /. When the input isn't a multiple of 3 bytes, the last group is padded with =, so Man becomes TWFu, Ma becomes TWE= and M becomes TQ==.
Text is first turned into bytes with UTF-8. That's why é becomes w6k=: it is two bytes in UTF-8 (C3 A9). A decoder that assumes a different encoding shows the same bytes as é.
Base64 examples
| Input | Base64 | Note |
|---|---|---|
hello | aGVsbG8= | 5 bytes, one = of padding |
user:pass | dXNlcjpwYXNz | How HTTP Basic auth sends a login, readable by anyone |
café | Y2Fmw6k= | é is two UTF-8 bytes |
?> | Pz4= or Pz4 | Standard, then URL-safe without padding |
| A 1×1 PNG image | data:image/png;base64,iVBORw0KGgo… | Every PNG starts with iVBORw0KGgo |
Tips and common mistakes
- Small images only. A data URI saves a request but can't be cached on its own and is a third larger. It suits icons and tiny images under a few kilobytes, not photos.
- Copied from an email or PEM file? Line breaks every 76 or 64 characters are normal there and are ignored when decoding.
- "Isn't a Base64 character" usually means a stray quote, a % escape from a URL, or two strings pasted together. The message gives the position.
- A JWT is three Base64url parts. Use the JWT decoder to read all of them at once.
Frequently asked questions
Is Base64 encryption?
No. Base64 only changes how bytes are written, so anyone can decode it in a second, as this page shows. It's used to carry binary data through places that only accept text, such as JSON, email or a URL. To protect data, encrypt it; Base64 adds no secrecy.
Why does btoa fail on my text?
The browser's btoa only accepts characters from Latin-1, so text with é, Chinese or emoji throws an error, and atob gives back mangled characters. This tool converts text to UTF-8 bytes first and back again when decoding, which is what almost every other system expects.
What is URL-safe Base64?
Standard Base64 uses + and /, which have special meanings in URLs and file names. The URL-safe alphabet (RFC 4648 section 5, also called Base64url) uses - and _ instead and usually drops the = padding. JWTs use it. The decoder here accepts both forms automatically.
How do I convert Base64 back to an image or file?
Choose Decode and paste the Base64 or the whole data: URL. If the bytes are an image, PDF, zip or another known file type, it's recognised from its first bytes, an image is previewed, and Download saves it with the right extension.
Why is the Base64 bigger than my file?
Every 3 bytes become 4 characters, so Base64 is about 33% larger than the original, plus a little for padding and any line breaks. A 30 KB image becomes about 40 KB of text.
Are my files uploaded?
No. Files are read and encoded by your browser on this device. Nothing is sent to a server, so it is safe for private images, keys and documents.