Skip to content
Kilnfile

Image to Base64

Encode an image as Base64 for inline use in HTML, CSS, JSON or email.

Processed on your device, nothing uploadedLast updated

To convert an image to Base64, drop a PNG, JPG, WebP, GIF or SVG on Kilnfile's Image to Base64 tool, choose Output as Data URI, Raw base64 only, HTML image tag or CSS background-image, click Convert to Base64 and copy the result. Encoding happens in your browser with no upload. Base64 is about 33% larger than the original file.

Your file stays in this tab.On your device
Options

How do I convert an image to Base64?

  1. Drop a single image file (PNG, JPG, WebP, GIF or SVG) onto the drop zone.
  2. Choose Output as: Data URI (for src="…"), Raw base64 only, HTML image tag, or CSS background-image.
  3. Click Convert to Base64.
  4. Click Copy output and paste the text into your HTML, CSS or code.

Base64 turns binary data into plain text using 64 safe characters, which lets an image live inside a file that can only hold text: an HTML page, a stylesheet, a JSON payload, an email body or a Markdown document. The browser decodes it on the fly, so the image displays without a separate request to a server. The cost is size. Every 3 bytes become 4 characters, so the encoded string is about 33% larger than the original file, and it cannot be cached separately from the document it is embedded in.

The tool reads the file's bytes in your browser and encodes them directly. The original data is used as-is, so a PNG stays a PNG and an SVG stays an SVG; nothing is re-encoded or resized. The MIME type is detected from the file and written into the data URI prefix, for example data:image/png;base64, so browsers know how to decode it.

The four outputs suit different destinations. Data URI is the general-purpose form you paste into an image src, a JSON field or an API request. Raw base64 only gives just the encoded string with no prefix, for systems that add their own or store it in a database. HTML image tag wraps the URI in a ready-to-paste img element. CSS background-image produces a url() declaration for a stylesheet, handy for icons on buttons and list markers.

Use Base64 sparingly. It is ideal for small assets, roughly under 10 KB, such as icons, logos, spinners and single-colour patterns, where saving an HTTP request outweighs the size penalty. For photographs and anything larger it makes pages heavier and slower to parse, and a normal image file with proper caching is the better choice. Compress or resize first if the asset is bigger than it needs to be; a 200 KB hero image as Base64 becomes 270 KB of text inside your HTML.

Nothing is uploaded. The file is read into memory, encoded and displayed in the page, and closing the tab discards it. That makes it safe to use for private assets and unreleased designs.

How it works: this tool uses your browser's Canvas and WebCodecs APIs, plus libheif for HEIC. No server is involved, so Kilnfile never sees your file. Last reviewed 20 September 2026.

Frequently asked questions

What is a Base64 image used for?

Embedding small images directly in HTML, CSS, JSON or email so they load without a separate file request. It is common for icons, logos and placeholders, and in APIs that only accept text.

Does Base64 make the image bigger?

Yes, by about 33%, because every 3 bytes of image become 4 text characters. That is why it suits small icons and not photographs.

What is the difference between a data URI and raw Base64?

A data URI has a prefix such as data:image/png;base64, followed by the encoded data, and can be pasted straight into an img src or CSS url(). Raw Base64 is just the encoded data with no prefix, for when the destination adds its own.

Can I convert an SVG or GIF to Base64?

Yes. SVG, GIF, PNG, JPG and WebP are all accepted. The file is encoded exactly as it is, so an animated GIF stays animated when embedded.

Is the image uploaded?

No. The file is read and encoded in your browser, and the result is shown on the page for you to copy. Nothing is sent to a server.

Cite this page: “Image to Base64 Converter Free, Data URI Output”, Kilnfile, https://kilnfile.com/image/image-to-base64/

Guides