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:
CommentsDrop 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.
Try Next
Unicode Escape
Escape and unescape Unicode sequences online. Convert any text to \uXXXX / \u{XXXX} form, or reverse escape sequences back to readable text. Handles surrogate pairs and emoji. 100% local.
Related Tools
Base64
Encode and decode Base64 strings online. Supports UTF-8 text and URL-safe Base64. All processing runs locally in your browser.
URL Encode/Decode
Percent-encode and decode URLs online. Handles query strings, path segments, and special characters correctly.
Base64 Image Decoder
Decode Base64 strings back to images. Paste a data:image/... string or raw Base64, and see the decoded image instantly. Useful for debugging data URIs and embedded images. 100% local.
Base32
Encode and decode Base32 strings online (RFC 4648). Handles TOTP / Google Authenticator secrets, DNSSEC records, and other case-insensitive binary-to-text formats. 100% local.
Base58
Encode and decode Base58 strings online — the alphabet used by Bitcoin addresses, Solana public keys, IPFS CID v0, and Flickr short links. 100% local, no padding, human-safe.
Punycode
Convert internationalized (IDN) domain names to and from their ASCII xn-- form. Follows RFC 3492 exactly — the same encoding your browser and DNS resolver use. 100% local.