Image to Base64 & Base64 to Image
Convert any image to base64, or decode base64 back into an image. Build data URIs and JSON payloads for free, privately in your browser with no upload.
- No file limits
- No registration
- Free forever
- Images never leave your browser
Paste data:image/... base64 below to preview and download the original image
Your images never leave your browser
All processing happens locally on your device. Nothing is uploaded to a server, stored, or tracked.
Turn any image into a base64 string for JSON payloads, APIs and inline embeds, or paste a data URI back into a working image. Encoding and decoding run entirely on your device, so the data never leaves your browser.
How it works
What base64 is for, and what it is not
Base64 is an encoding, not a compression. It rewrites binary data using 64 printable characters so it can travel safely inside text: a JSON body, an HTML attribute, a CSS file, an email. The output is always about a third larger than the input, which is the opposite of what people expect from a tool described as a converter. It is genuinely useful in those specific places, and genuinely wasteful as a way of storing or sending an image file.
| Situation | Use base64? | Why |
|---|---|---|
| Inline image in HTML or CSS | Yes | Avoids a separate request, and no file to host |
| Embedding an image in JSON | Yes | JSON cannot carry raw binary safely |
| Email with no attachments | Sometimes | Works, but bloats the message and is blocked by many clients |
| Storing images in a database | Rarely good | Adds a third overhead and bloats every row read |
| Sending an image over HTTP | No | A multipart upload is smaller and standard |
| Sharing or archiving an image | No | Just send the file |
Why the encoded string is bigger than the file
Every three bytes of binary data become four characters of base64, because 64 possible characters encode six bits each and a byte is eight. That arithmetic is fixed, so a 100 KB image becomes roughly 133 KB of text, before any line breaks or whitespace are added. This is worth knowing precisely because the growth is often a surprise, and because it means base64 can never be used to meet a size limit.
- A 3 byte group becomes 4 characters, always.
- Expect about 33 percent growth, plus any whitespace in the output.
- A data URI also carries a prefix such as image/png;base64 before the data.
- If you need a smaller file, resize or compress it. Base64 will not help.
NoteThe conversion runs in your browser. Nothing is uploaded, which matters for the common case of embedding a private screenshot or document.
Data URIs and the prefix that matters
When you see base64 in HTML, it is usually wrapped in a data URI rather than being raw text. The prefix declares the media type and says the data is base64, and the browser cannot render the image without it. A common mistake is pasting an image into a data URI without declaring whether it is PNG or JPG, which produces something that looks correct and silently fails to load.
- Full form: data:image/png;base64,iVBORw0KGgo...
- The media type must match the actual format of the data.
- The base64, marker is required before the data.
- Keep the whole thing on one line. Whitespace inside a data URI breaks it in some contexts.
Decoding safely, and the limits to know
Decoding reverses the process and is where problems show up. A truncated string produces a partial file, and a string that was never valid base64 produces nothing useful rather than an error message. Very large images are also a practical constraint: the encoded text is a third bigger, and pasting several megabytes of text into an editor is slow or impossible. Decoding what you actually intend to use is a sensible habit.
- A truncated string gives a corrupt or partial image, not a helpful error.
- Check that the data is complete before decoding, especially if it was copied from a terminal.
- Very large images produce unwieldy text. Resize first if the image is big.
- Never decode untrusted base64 expecting it to be safe. It is still data, and a file is only as trustworthy as its type.
- In HTML, use a real file URL when you do not need the inline behaviour.
Frequently asked questions
What is base64 for?
It turns binary image data into plain text, handy for JSON APIs, data URIs and inline embeds that cannot carry binary files.
Does base64 make a file bigger?
Yes, base64 adds roughly a third of the original size, so it is best for smaller images and favicons rather than large photos.
Can I decode a data URI back to an image?
Yes, paste the full base64 string and the tool restores the original image, ready to view and download.