Image to Base64 Converter (Data URL)
Convert images to Base64 data URLs online. Drop or select any image and copy the ready-to-paste data URI for CSS, HTML, or JSON.
Last updated:
Drop or select an image above to convert it into a Base64 data URL you can paste into CSS, HTML, or JSON. Conversion happens in your browser with FileReader — nothing is uploaded.
What is Image → Base64?
Converting an image to Base64 produces a data URL — a self-contained string like data:image/png;base64,iVBOR... that embeds the entire image inline, no separate file or HTTP request needed. It's handy for tiny icons, email templates, offline single-file HTML, and CSS backgrounds. The conversion runs locally using the browser's FileReader API, so your image never leaves your device.
How to convert an image to Base64
- 1Drag an image onto the drop zone, or click to select a file.
- 2The tool reads it locally and produces a full data URL with the correct MIME type.
- 3Copy the data URL, or grab a ready-made CSS/HTML snippet.
- 4Paste it into a stylesheet (background-image), an <img> src, or a JSON field.
Use Cases
Inline small icons in CSS
Embed a favicon or tiny icon as a data URL to remove an HTTP round-trip and simplify deployment.
Build self-contained HTML
Ship a single .html file with images baked in — useful for offline docs, email, and exports.
Store images in JSON
Embed a small image in a JSON payload or config where a separate binary file isn't practical.
Code Examples
As a CSS background
.logo {
background-image: url("data:image/png;base64,iVBORw0KGgo...");
}As an img tag
<img src="data:image/png;base64,iVBORw0KGgo..." alt="logo" />Key Concepts
- Data URL
- A URI scheme that embeds file contents inline: data:[mime];base64,[payload]. The browser treats it like any other resource.
- MIME type
- The media type prefix (image/png, image/svg+xml) tells the browser how to interpret the bytes. It's auto-detected from your file. See the full MIME types reference for every media type.
- 33% size overhead
- Base64 encodes 3 bytes into 4 ASCII characters, so the string is ~33% larger than the original binary.
Tips & Best Practices
- ▸Only inline small images (roughly <10 KB). Larger images are better linked so browsers can cache them.
- ▸SVGs can often be embedded as plain text (utf8) instead of Base64 for a smaller, still-inline result.
- ▸Data URLs can't be cached separately, so every page load re-downloads the inline bytes — a tradeoff vs fewer requests.
- ▸Base64 is encoding, not compression — optimize/compress the image before converting.
Frequently Asked Questions
Are my images uploaded to your server?
No. The conversion happens in your browser using the FileReader API. Nothing is transmitted anywhere.
When should I inline images as Base64 vs linking them?
Inline (Base64) is great for tiny icons or in situations where you must ship a single self-contained file (e.g. an offline HTML). For anything larger than ~10KB, HTTP linking is faster and cacheable.
Which formats are supported?
Any format your browser can read: PNG, JPG, GIF, WebP, SVG, AVIF, ICO, BMP. Output is always a full data URL prefixed with the correct MIME type.
Related Tools
Base64
Encode and decode Base64 strings online. Supports UTF-8 text and URL-safe Base64. All processing runs locally in your browser.
HTML Encode/Decode
Encode and decode HTML entities (&, <, >, ", numeric references). Useful for sanitizing user content or debugging escaped markup.
JSON Formatter
Format, beautify, and validate JSON online. Free, fast, and 100% local — your data never leaves your browser.
JSON Validator
Validate JSON online with instant error location and structure statistics (depth, keys, node types). 100% local — your JSON never leaves the browser.
JSON → TypeScript
Convert JSON to TypeScript interfaces instantly. Generate strongly-typed TS types from any JSON sample.
JSON → Go
Convert JSON to Go structs online. Generates idiomatic Go structs with proper json tags and PascalCase field names.