Image to Base64 converter
Turn an image into a data URI, raw Base64, an img tag or a CSS background, or paste Base64 to get the image back. Nothing leaves your browser.
Choose an image to encode
The file is read and encoded in your browser. Nothing is uploaded.
Drop images here, or tap to select
JPG, PNG, WebP, GIF, SVG, AVIF, BMP, ICO · one file · Up to 10 MB each
Base64 writes binary data using 64 plain characters, so an image can sit inside HTML, CSS, JSON or an email as text. This page converts both ways. Image → Base64 gives you a data URI, the raw Base64 string, a ready img tag or a CSS background-image line, each with Copy and a .txt download. Base64 → Image takes pasted text, finds the real format from the decoded bytes and gives you the file back. Everything runs in your browser; nothing is uploaded.
Why Base64 is a third bigger
Every 3 bytes of the file become 4 characters, and the last group is padded with = to a multiple of 4. The text is therefore about 33.3 % larger than the image: a 300,000-byte photo becomes 400,000 characters. The page shows both numbers and the exact growth for your file.
When the HTML or CSS is served with gzip or Brotli, most of that overhead is won back, because each Base64 character carries only 6 bits of data and the compressor recovers much of the rest. The gzipped text of a JPG ends up close to the size of the JPG itself. Gzip cancels the Base64 penalty; it does not make the image smaller than the file.
When inlining helps and when it hurts
A data URI saves one request, which helps for small things: a 1 KB icon, a loading spinner, a background pattern in a CSS file. The cost is that the image can no longer be cached on its own. It is downloaded again with every page or stylesheet that contains it, and the browser has to parse it before it can render. Above roughly 100 KB of Base64 the page warns you, since a normal image file with a long cache lifetime will almost always load faster.
The img snippet includes width and height when the image has them, so the browser reserves space and the layout does not jump. For SVG, a percent-encoded data URI (data:image/svg+xml,…) is often shorter than Base64; the decoder side of this page accepts both.
Images in HTML email
Developers often try Base64 to put a logo inside an HTML email without hosting it. Email clients do not treat data URI images the same way, and some strip or block them, so send a test to the clients your readers actually use before relying on it. For a newsletter that must look right everywhere, a hosted image or a CID attachment is the safer choice; for an internal tool or a single known client, inline Base64 can be enough.
Decoding: what the page checks
Paste a full data URI or just the Base64 part. Line breaks, spaces, quotes and wrappers such as src="…" or url(…) copied along with the value are ignored, and URL-safe Base64 (with - and _) works too. The format is read from the first bytes of the result, not from the MIME type in the data URI. If a string says image/jpeg but contains PNG data, you get a note and a file saved as .png. A JPG pasted in and downloaded again is byte-for-byte the original, with the same size and the same content. Invalid characters, a cut-off string or data that is not an image each produce their own error message.
How to convert an image to Base64
Choose the direction
Image → Base64 to encode a file, Base64 → Image to decode text.
Add the image
Drop or choose one JPG, PNG, WebP, GIF, SVG, AVIF, BMP or ICO file up to 10 MB.
Pick the output
Data URI, Base64 only, HTML img or CSS. The size and the 33 % growth are shown beside the preview.
Copy or download
Press Copy, or download the text as a .txt file.
Frequently asked questions
- What is the difference between a data URI and Base64?
- Base64 is only the encoded text. A data URI adds the prefix data:image/png;base64, in front of it, so browsers know the type and can use it directly in src or url().
- How much larger does an image get in Base64?
- About 33 %: 4 characters for every 3 bytes, plus up to two = signs of padding. A 30,000-byte file becomes exactly 40,000 characters.
- How do I turn Base64 back into an image?
- Switch to Base64 → Image and paste the text. The page shows a preview, the format and the pixel size, and downloads the file with the right extension.
- Why does it say my Base64 is cut off?
- A valid string cannot have a length that leaves a single character over after groups of four. That usually means the copy stopped early, which happens with very long strings in some editors.
- Is my image sent to a server?
- No. Encoding and decoding happen in your browser with its built-in functions. The page works the same with the network turned off once it has loaded.
Recommended tools
Based on your current tool, you might also find these useful