Image to Base64 Converter: Data URI, HTML & CSS
Drop a PNG, JPG, WebP, GIF or SVG up to 20 MB and copy raw Base64, a data URL, an <img> tag or a CSS url(). Runs in your browser, nothing uploaded.
Updated November 2026
Reviewed by Rafael Duarte
Low Latency Encoding
Asynchronous processing handles large files without blocking the UI.
Local Processing
Assets are encoded in-browser. Data never leaves your machine.
Data URI Support
Directly generate CSS, HTML, and Data URL ready string formats.
How to convert an image to Base64
Four output formats, one click to copy
1. Drop the image
Drag a PNG, JPG, GIF, SVG or WebP file up to 20 MB onto the box, or click browse. Other image types such as AVIF, BMP or ICO also work if your browser recognizes them. One file at a time.
2. Pick the output format
Raw Base64, Data URL, HTML <img>, or CSS url().
3. Copy the result
Click Copy, or press Shift+Enter while the focus is outside the output box and other text fields.
What this Base64 image encoder does
More than just spitting out a string
Four output formats
Raw Base64, a full data URL, a ready-to-paste <img> tag, or a CSS url() value.
Shows image metadata
METADATA ANALYSIS lists the type, dimensions, File Size and Encoded Size, so you can see the roughly 33% Base64 overhead before you paste anything.
Zoomable preview
Open View image and zoom from 25% to 400% to check the picture before embedding it in your code.
Runs entirely in your browser
The FileReader API reads the file locally, so nothing is uploaded. Once the page has loaded, the conversion itself needs no network.
Examples
When you'll reach for this tool
The most common scenarios among people converting images to Base64
Cut HTTP requests
Small icons and logos (under 5–10 KB) load inline with the HTML/CSS, skipping an extra network round trip.
Self-contained HTML
Single-file demos, prototypes, or offline docs work with zero external dependencies.
Previewing email templates
Handy for testing a layout locally, but support for data URL images varies between email clients. For real sends, hosted images or inline CID attachments are the safer choice.
API payloads
Webhooks and REST APIs that transfer images usually expect a Base64 string in the request body.
Canvas and WebGL
Base64 strings sidestep the CORS restrictions that apply to externally hosted images.
Going the other way
To paste Base64 and get the image back, use Base64 to Image. For text and other files, the Base64 Encoder is the right tool, and How to convert Base64 to text, image and file walks through every direction.
Common questions
Image too large to embed
Above a few KB, hosting the file separately usually beats inlining it as Base64.
Quality doesn't change
Base64 is lossless: the string represents exactly the same pixels as the original file.
Why encode here
Every conversion happens in the browser with the FileReader API, so your image is never uploaded. After the page has loaded, encoding needs no network connection.
The four output formats save you from hand-building the <img> tag or the CSS url() value: pick the one you need, copy it and paste it straight into your code. If you only need to encode text or a non-image file, use the Base64 Encoder instead.
Frequently asked questions
Use the data URL output and paste it as the src of an <img> tag, or pick the HTML <img> output format directly, since the tool already generates the full tag for you.
Copy the CSS url() output. It produces something like url('data:image/png;base64,...'), ready to paste into background-image or content.
20 MB per file. Keep in mind that Base64 makes the data about 33% bigger, which you can see by comparing File Size with Encoded Size. Long strings bloat your HTML or CSS, so hosting the file separately is usually the better call above a few dozen KB.
No. Base64 is a lossless encoding. It converts binary data to text and back without touching a single pixel.
No. The entire conversion runs locally using the FileReader API, and the tool makes no network request with your file. Your image never leaves your device.
The most common cause is pasting Raw Base64 where a full data URL is expected: the browser needs the data:image/png;base64, prefix. Pick Data URL, HTML <img> or CSS url() instead. Also check that you copied the whole string, since a truncated Base64 payload won't render.
Drop the file on the box, choose the output (Raw Base64 is selected by default) and click Copy. The same steps work for WebP, GIF and SVG; the MIME type in the prefix, such as image/png or image/jpeg, is taken from the file you dropped.
In practice, none. Both names describe the same data: scheme, such as data:image/png;base64,.... This tool labels the option Data URL.
Not always. An SVG is already text, so a URL-encoded data:image/svg+xml,... string is often shorter than its Base64 version. This tool only produces Base64 (data:image/svg+xml;base64,...), which works everywhere but costs about a third more bytes.
References
Related Tools
- Base64 to Image Online: Preview and Save PNG, JPG, GIF Developer Paste raw Base64 or a data:image URL to preview the image with its type, dimensions and size, then save the original file. No upload, runs in your browser.
- Base64 Encoder: Encode Text, PDF & Files Online Developer Encode UTF-8 text or any file (PDF, DOCX, XLSX, ZIP up to 50 MB) to Base64 or Base64URL. Runs in your browser, nothing is uploaded. Free, no sign-up.
- Base64 Decode Online — Free Base64 to Text Decoder Developer Free online Base64 decoder — decode Base64 strings back to plain text instantly in your browser. Validates input and shows decoded payload size.
- HTML Entity Encoder: Escape HTML Characters Online Developer Escape <, >, &, quotes and accents as HTML entities (<, &, é) in Essential, Named or Numeric mode. Runs entirely in your browser.
- URL Encoder: Encode Query Strings, Spaces & UTF-8 Developer Turn spaces, accents and symbols into %20, %C3%A9 and %26 for links and query strings, with spaces as %20 or +. Runs locally in your browser.