Image to Base64 & Back · Tutorial

How to extract an embedded image from CSS or HTML

5 min readbeginnerUpdated

A stylesheet or HTML file contains an icon embedded as a long data:image/... string, and you need the actual image, to edit it, replace it or reuse it elsewhere. This tutorial shows how to copy the embedded data, decode it, and save it as a file.

What you need

  • The Image to Base64 & Back converter
  • The CSS or HTML containing the embedded image (the Try it button loads a CSS line with a small icon)

Steps

  1. Find the data URL

    In your stylesheet or HTML, search for data:image. It usually appears inside url(...) in CSS or in an src="..." attribute in HTML. The string can be thousands of characters long.

  2. Copy it, with or without the wrapper

    Copy the whole value. You don't need to trim it precisely, because the tool accepts the complete background-image: url("data:…"); line, just the url(...) part, or the bare data URL.

  3. Paste and preview

    Paste it into the box. The image appears straight away with its type, file size and dimensions. The sample is a 16 × 16 pixel PNG icon of an orange rounded square.

  4. Download the file

    Press Download image. The file is saved with the correct extension, in this case image.png, ready to open in any image editor.

  5. Replace the embedded version (optional)

    If the embedded image was large, consider replacing the data URL with a link to the saved file, such as url("/images/icon.png"). Separate files can be cached by the browser and keep your CSS small.

Try it yourself

Opens the Image to Base64 & Back with this tutorial's sample loaded.

Try it now

Common mistakes

Copying only part of the string
Long data URLs are easy to cut short when copying. If the preview is broken or missing, select the whole value again, from data: to the closing quote.
Mixing up URL-encoded and Base64 SVGs
Some SVG data URLs aren't Base64 at all. They contain readable XML with %3C escapes, and there's no ;base64 in the prefix. Decode those with URL Decode instead.
Ignoring licences
An image embedded in someone else's site may be copyrighted. Extract images to edit your own work, or check that you're allowed to reuse them.

Next steps

Go back to the Image to Base64 & Back, or keep going with one of these:

FAQ

Can I extract several images at once?

Decode them one at a time. Search your file for each data:image occurrence and paste them in turn.