FREE
Loading…
Drop an image here or click to browse
PNG, JPG, GIF, WebP, SVG supported
Convert any image to a Base64 data URI for embedding in HTML, CSS, or email — browser-only.
Encode Image to Base64
Processing…
FREE
Loading…
Drop an image here or click to browse
PNG, JPG, GIF, WebP, SVG supported
Encode Image to Base64 turns any image file — PNG, JPG, GIF, WebP, or SVG — into a Base64 text string you can drop straight into HTML, CSS, JSON, or a config file as a self-contained data URI. Instead of a URL like /images/logo.png, you get an inline string like data:image/png;base64,iVBORw0KGgo... that carries the entire image's bytes as text. Paste it into an <img src> or a CSS background-image and the browser decodes and renders it with no separate HTTP request at all.
The technique matters because there are specific situations where an extra network round trip is worse than a bigger inline payload. A tiny UI icon, a company logo in a transactional email, a favicon fallback, or a placeholder image in a component library are all good candidates — they are small enough that the ~33% Base64 size overhead is trivial, and skipping the request avoids DNS lookups, TLS handshakes, and render-blocking waits for a resource the page needs immediately. HTML email is the clearest case: most email clients strip external image requests by default or show a "download images" prompt, so inlining small graphics as Base64 (or as CID attachments) is often the only way to guarantee an image actually renders when the message opens.
It is easy to overuse, though. Because HTTP/2 and HTTP/3 multiplex many requests over one connection, the old justification of "fewer requests is always faster" is much weaker today than it was in the HTTP/1.1 era — browsers can fetch a dozen small icons in parallel almost as cheaply as one. A Base64-encoded image also cannot be cached independently by the browser; it lives inside whatever HTML, CSS, or JS file references it, so every time that file is requested, the full image weight is downloaded again, and updating the image means invalidating that entire file's cache. For anything above a few kilobytes — hero images, product photos, screenshots — a normal file reference with proper HTTP caching headers will almost always outperform an inline data URI.
This tool encodes everything locally using the browser's FileReader API. Your image file is read directly from disk into memory and converted to a string without ever touching a server, which makes it safe to encode screenshots, internal diagrams, or anything else you would rather not upload anywhere.
The tool calls the browser's FileReader.readAsDataURL() method on your selected file. FileReader reads the raw bytes of the image asynchronously and, on the load event, returns a string in the exact format data:[mediatype];base64,[data] — for example data:image/png;base64,iVBORw0KGgo.... The "mediatype" segment is the MIME type the browser detected from the file (image/png, image/jpeg, image/svg+xml, etc.), and everything after the comma is the Base64-encoded byte stream. The tool splits that string so you can copy either the full data URI (ready to paste into an src or url() property) or just the raw Base64 payload (useful for JSON fields, config values, or API bodies that already wrap the mediatype themselves). No image data is transmitted anywhere during this process — the encoding is pure client-side string manipulation.
Upload an image
Drag a PNG, JPG, SVG, GIF, or WebP file onto the drop zone, or click it to open your file picker. The file is read locally — nothing uploads to a server at this stage.
Encode
Click "Encode Image". The tool runs FileReader.readAsDataURL() in your browser and converts the binary image data into a Base64 data URL string in under a second, even for larger files.
Check the preview and size
A live preview confirms the correct image was encoded, and the panel shows the original file size next to the encoded character count so you can judge the ~33% overhead before committing to inlining it.
Copy the format you need
Copy the full data URI (data:image/png;base64,...) for direct use in an <img src> or CSS url(), or copy just the raw Base64 string if you're inserting it into a JSON field, environment variable, or API payload that already specifies the MIME type separately.
Paste into your project
Drop the data URI directly into HTML (<img src="data:image/png;base64,...">), CSS (background-image: url("data:image/png;base64,...")), or an email template — the browser or mail client decodes and renders it inline with no extra request.
Inline HTML Images
Embed small icons or logos directly in HTML files using a data URI so no extra HTTP request is needed.
CSS Backgrounds
Use a Base64 data URI as a CSS background-image to bundle decorative images directly into your stylesheet.
HTML Email Images
Inline images in HTML emails using Base64 to ensure they always display without relying on external hosts.
Single-File Documents
Pack images into a single-file HTML document so it remains fully self-contained for offline sharing.
API Payloads
Encode images to Base64 strings for inclusion in JSON API payloads or configuration files.
Prototyping & Testing
Quickly get a data URI for a placeholder image when building UI prototypes without a file server.
100% Private
The browser's FileReader API encodes the image locally — your file is never transmitted anywhere.
Full Data URI Output
Provides the complete data:image/...;base64,... URI ready to paste directly into HTML or CSS.
Raw Base64 String
Also outputs the raw Base64 string separately for use in JSON payloads or other non-HTML contexts.
Live Image Preview
A preview of the encoded image is shown alongside the output so you can verify it before copying.
Character Count Display
Shows the exact encoded string length so you can judge the size impact before embedding.
All Image Formats
Accepts PNG, JPG, GIF, WebP, SVG, and any other browser-readable image format.
Also Known As
Binary To Decimal
Convert between binary, decimal, hex and octal number systems
Color Converter
Convert colors between HEX, RGB, and HSL formats
Convert Binary
Convert binary numbers to text and text to binary
Convert Timestamp
Convert Unix epoch timestamp to standard date format and back
Count Words
Count words, characters, sentences and paragraphs in text
Convert Datetime
Convert datetime between different formats and timezones
Trusted Worldwide
iLoveDocsTools is used by students, professionals, and businesses across the United States, Canada, United Kingdom, Australia, India, and more than 100 other countries. All tools are browser-based and process files privately — your files never leave your device. Free to use, with Pro plans for unlimited access.
All processing happens directly in your browser. Your documents are never sent to any server — complete privacy guaranteed for users in the USA, Canada, UK, and worldwide.
Every tool on iLoveDocsTools is free to use. Need more? Upgrade to Pro for unlimited usage, priority access, and no daily limits. Trusted by students, freelancers, and teams across North America and Europe.
Whether you are on a Mac, Windows PC, iPhone, or Android in New York, Toronto, London, or Sydney — our tools work instantly in any modern browser.
Looking for free PDF tools in the USA? Free document converters in Canada? Online PDF editors in the UK or Australia? iLoveDocsTools offers 70+ free tools — merge PDF, split PDF, compress PDF, convert Word to PDF, Excel to PDF, JPG to PDF, and many more — all free, all instant, all private. No watermarks. No file size limits. Just free tools that work.