Image to Base64
Convert images to Base64 encoded strings for embedding in HTML, CSS, or JSON.
Drop your image here
or click to browse • PNG, JPG, WebP, GIF
Related Tools

About This Tool
Encode any image into a Base64 string you can paste directly into HTML, CSS or JSON — no file hosting needed. Developers use it to inline small icons and logos into stylesheets, embed images in single-file HTML emails, or ship assets inside JSON payloads and configuration files. The tool shows the encoded string with its exact byte size and the resulting data-URI length, so you know whether inlining actually saves a request.
How to Use This Tool
- Drop the image (PNG, JPG, WebP, SVG, GIF) into the zone.
- Copy the generated data URI with one click — the format selector switches between CSS (url), HTML (src) and raw Base64.
- Check the size readout: Base64 inflates the file by about 33%.
- Paste into your stylesheet or markup.
- For files over ~10 KB encoded, compare with a regular file reference — inlining is only a win for small assets.
Advantages & Use Cases
Inline a 2 KB logo into transactional email HTML so it renders without remote images, embed icons into a single-file demo or offline documentation, or ship an image inside a JSON API response for a kiosk app. It is also the standard way to add background patterns into CSS without an extra HTTP request.
Supported Formats & Recommendations
- PNG and SVG encode cleanly; SVG as data-URI must be URL-encoded — the tool handles that automatically.
- JPG encodes fine but Base64 does not compress further; shrink the JPG first for smaller output.
- Keep inlined assets under ~5-10 KB; bigger ones belong in real files cached by the browser.
How We Test This Tool
Round-trip testing on every release: encode a reference PNG, decode the produced string, and require byte-identical output. The three output formats (CSS, HTML, raw) are validated against real browsers — a test page using the emitted CSS renders the image identically.
Related Tools You May Like
Helpful Resources
Frequently Asked Questions
Why is the Base64 string bigger than my file?
Base64 encodes 3 bytes into 4 characters, a fixed +33% overhead. That is the price for making binary data text-safe; small assets still win because they save an HTTP round-trip.
Can I inline an image in an email this way?
Yes — data URIs are the reliable way to show images in transactional HTML email. Keep total inline weight under ~100 KB to avoid spam-filter heuristics and Outlook clipping.
Does Base64 embedding work in CSS background-image?
Yes, use the CSS mode output: background-image: url(data:image/png;base64,...). The tool emits the complete ready-to-paste declaration.