Image to Base64 Converter
Convert an image into a Base64 data URI ready to paste into CSS, HTML or JSON, with the size overhead shown.
Loading tool…
The image is read and encoded in your browser. It is not uploaded.
What the Image to Base64 Converter does
This image to base64 converter will convert an image into a Base64 data URI ready to paste into CSS, HTML or JSON, with the size overhead shown. Everything runs inside this page, so the work happens on your own device rather than on a server. It is most often used for embedding a small icon in a stylesheet to save a request. If you need the other side of this job, there is also a signature maker.
How to use it
- Choose an image — small icons and logos work best.
- The data URI is generated immediately.
- Copy the raw string, or the ready-made CSS or HTML snippet.
- Check the size warning before embedding anything large.
How it works
A data URI embeds the image bytes directly in the markup or stylesheet, so the browser needs no separate request to fetch it. Base64 encoding adds roughly 33 per cent to the size, which the tool reports alongside the original.
This is worth doing for small assets — icons, tiny background patterns, a logo under a few kilobytes — where saving a round trip outweighs the size penalty. It is counterproductive for anything large: an embedded image cannot be cached separately, so it is re-downloaded with every page load, and it blocks the stylesheet or HTML from parsing until the whole string is read.
For an SVG icon, embedding the SVG source directly is almost always better than Base64 — it is smaller, it compresses well with gzip, and it can be styled with CSS.
When to use it
- Embedding a small icon in a stylesheet to save a request.
- Including an image in a single-file HTML document or email template.
- Putting an image into a JSON payload or configuration file.
Common mistakes to avoid
- Embedding large photographs, which bloats the page and defeats browser caching.
- Using Base64 for an SVG when the raw SVG source would be smaller and styleable.
- Forgetting that an embedded image cannot be cached independently of the file containing it.
Frequently asked questions
When should I use a data URI?
For assets below roughly 5 KB that appear on most pages, where saving a request outweighs the 33 per cent size penalty and the loss of separate caching. Above that, a normal image file is better.
Why is the Base64 larger than the file?
Base64 encodes three bytes as four printable characters, a 33 per cent increase. That is the cost of representing binary data in a text-only context.