Tools · Bild · Bild in Base64 umwandeln · Anleitungen · How to Embed an Image Directly in Your HTML, No File Needed
How to Embed an Image Directly in Your HTML, No File Needed
Turning an image into something you can paste straight into HTML or CSS takes one drop and one click - the encoding itself is instant, and the tool hands back three different ready-to-use snippets rather than just the raw string, since what you paste depends on where it's going.
Drop the image
On the image to Base64 tool, drop or choose up to 20 image files at once - this is genuinely a batch tool, useful for encoding a whole small icon set in one pass rather than one at a time. There's no separate Run click needed: the moment a file is selected, encoding happens automatically, since the operation itself is a single, near-instant browser call with nothing worth putting a manual step in front of.
What happens during encoding
The tool reads each file with the browser's built-in FileReader API, which returns the complete data URI directly - MIME-type prefix and Base64 payload both included, computed by the browser itself. There's no image decoding step at all: the file's raw bytes are what get encoded, not a re-rendered version of the pixels. This matters for two real reasons. First, it works on any file the browser can read as a file, not just formats it can visually decode - so SVG, ICO, TIFF, and even formats a given browser's <img> tag can't preview (HEIC in most browsers, for instance) can still be encoded successfully, even if the live thumbnail preview can't show what it looks like. Second, an animated GIF's animation survives completely intact, because the original bytes - including every frame - are what get encoded, unlike a canvas-based re-encode which would flatten an animated image down to a single static frame.
Read, encode, done
Pick the snippet you need
Each result card gives you three separate Copy buttons, because the same data URI gets used differently depending on context. Copy data URI gives you the raw data:image/...;base64,... string on its own - useful for a JSON config field or anywhere you need just the value. Copy <img> tag wraps it in a complete <img src="data:..."></code> element with an empty alt="" placeholder - deliberately empty, since real alt text describing the image is something only you know and should fill in, never invented for you. Copy CSS wraps it as background-image: url("data:...");, ready to drop into a stylesheet rule or an inline style.
Checking it worked
Each result card shows a live thumbnail rendered directly from the produced data URI, which doubles as a correctness check: if the encoding somehow produced a malformed string, the thumbnail simply wouldn't render, which is a visible, honest failure signal rather than a string that merely looks plausible. For a format your browser can't preview at all (some HEIC or TIFF files, depending on the browser), you'll see a plain notice instead of a broken image icon - "Encoded successfully, this format can't be previewed in your browser, but the data URI is correct" - since a failed preview isn't the same thing as a failed encode.
If the result is too big to copy comfortably
For a larger image, the resulting text can run to hundreds of thousands of characters, which is workable to copy but not always pleasant. Each card also has a Download as .txt link, which saves the raw data URI string as a plain text file - useful when you'd rather open it in a text editor than paste a giant string through the clipboard, or when you're handing the file to someone else rather than pasting it yourself.
The tool also shows both sizes side by side on every card - the original file size and the inflated Base64 size, with the percentage difference - so you know upfront whether the string you're about to embed is a reasonable size for where it's going. If you want the full explanation of why that inflation happens and when it's worth accepting, see this guide. And for the broader case for embedding at all versus linking a file, see why use a data URI for images.
What doesn't work here, and why
This tool only goes in one direction: image file to data URI. If you already have a data URI string and want the original image file back out of it, that's a separate operation - decoding a Base64 string back into a downloadable file - which this particular tool doesn't perform. It's worth being clear about that upfront rather than discovering it after pasting a string in expecting a reverse conversion; the scope here is deliberately narrow, encode only, which is also why the tool needs no configuration options beyond dropping a file.
Formats worth knowing behave differently
Since nothing is decoded to pixels, encoding works uniformly across formats in a way a canvas-based tool couldn't - but the live thumbnail preview is a separate step that does depend on what the browser can actually display. A JPG, PNG, WebP, or GIF previews normally in every current browser. An SVG previews too, safely, because it's rendered through an <img> element rather than as live, executable markup - the one format in this batch where rendering safety is a real, specific concern rather than a formality, since an SVG file can technically embed a script tag. A format like HEIC or TIFF, which many browsers can't display inline at all regardless of how it's referenced, encodes successfully but shows the "can't be previewed" notice instead of a thumbnail - not a failure, just an honest statement about what your specific browser can render versus what it can encode.