Image to Base64 Converter
About this tool
About Image to Base64
Drop a PNG, JPG, GIF, WebP, SVG, BMP, ICO or AVIF file and get its Base64 data URI straight away, together with the code you actually paste into a project: a CSS rule with background-image and the image's real width and height, an <img> tag with width, height and editable alt text, a Markdown image, or the bare Base64 string. The preview shows the image on a transparency grid with its format, pixel dimensions, file size and how much larger the data URI is than the file, usually about a third. Inlining suits small icons, loading spinners and email signatures, and the tool warns you when an image is big enough that a normal file would load faster. Flip the direction to Base64 → Image to check a data URI from someone else's code: it decodes it, identifies the real format from the first bytes, shows it, and lets you download it. Everything runs in your browser.
Built and maintained by Abhi JainUpdated
How to Convert an Image to Base64
- 1
Drop an image
Drop a PNG, JPG, GIF, WebP, SVG or ICO file onto the box, or click to choose one.
- 2
Pick the snippet
Choose Data URI, CSS, HTML, Markdown or Base64 above the code. Edit the Alt text for the HTML and Markdown versions.
- 3
Copy it
Click Copy to put the full code on your clipboard and paste it into your stylesheet, page or README.
Image to Base64: questions and answers
How do I use a Base64 image in CSS?
Put the data URI inside url(), for example background-image: url("data:image/png;base64,iVBOR..."). The CSS tab writes this rule for you, including the image's width and height.
Should I inline images as Base64?
Only small ones. A data URI saves an HTTP request but is about 33% larger than the file and can't be cached separately from the HTML or CSS it sits in. Icons of a few kilobytes are a good fit; photos are not.
Does converting to Base64 reduce image quality?
No. Base64 stores the exact bytes of the file, so the image is identical. To make it smaller, compress or resize the image before converting.
Can I convert SVG to Base64?
Yes. SVG becomes data:image/svg+xml;base64,... and works in CSS and <img>. For SVG you can also URL-encode the markup instead, which is often shorter; the URL Encoder can do that.
Are my images uploaded?
No. The file is read and encoded by your browser, and nothing is sent to a server.
Ready-made Image to Base64 presets
Related Tools
- Base64 EncoderEncode and decode Base64 for text and files, with URL-safe, MIME and data URL options.
- URL EncoderPercent-encode and decode URLs and query values with encodeURIComponent, encodeURI or form encoding.
- CSS Gradient GeneratorLinear, radial and conic CSS gradients with a live preview.
- SVG OptimizerMinify and clean SVG files with SVGO: smaller files, same look, side-by-side check.
- HTML Entity EncoderEscape text to HTML entities (named, decimal or hex) and decode entities back to characters.