Pular para o conteúdo
Tool

Image to Base64

Quickly generate the Base64 code (data URI) of any image to embed it directly in HTML or CSS.

Image to Base64

Convert image files into a Base64-encoded string to use in CSS or HTML

Upload an image

Supports PNG, JPG, WEBP, SVG, GIF and more. The conversion runs locally.

What it is

The Image to Base64 Converter turns a picture into a long line of text that represents the very same bytes. That text can be pasted straight into HTML, CSS, JSON or a JavaScript file, and the browser will draw the image without ever making a separate request for it.

How to use it

  1. Add the image by dragging it in or picking it from your device.
  2. Copy the result in the form you need: the raw base64, a ready data: URI, an <img> tag or a CSS background-image rule.
  3. Paste it into your code.

When embedding an image is a good idea

The reason to do this is to remove an HTTP request. A small icon that lives inside the CSS file loads with the CSS, so there is no second round trip to the server and no flash of a missing image.

That works well for small things: an icon, a logo in an email signature, a placeholder, a tiny texture. It stops working well as the file grows, because base64 makes the data about 33% bigger than the original binary, and because an embedded image cannot be cached separately: change one byte of the CSS and the browser downloads the picture again along with it.

A rough rule that holds up in practice: under a few kilobytes, embedding usually wins. Above that, a normal image file that the browser can cache almost always wins.

Where the file goes

Nowhere. The encoding happens inside your browser, so the image is never uploaded, never stored and never seen by anyone else. There is no limit and no account.

To go the other way and turn base64 back into a picture, use the base64 to image decoder.

Frequently asked questions

What is a base64 image?

It is the same image written as text instead of binary. Browsers understand it through a data: URI, which lets you put the picture directly inside HTML or CSS rather than linking to a separate file.

Does base64 make the file bigger?

Yes, by about 33%. Base64 uses four text characters for every three bytes of data. That overhead is why embedding only pays off for small images.

When should I embed an image instead of linking to it?

For small assets, roughly a few kilobytes or less: icons, a logo in an email signature, a placeholder. Above that a normal image file wins, because the browser can cache it separately from your code.

Is my image uploaded anywhere?

No. The encoding runs in your browser. The file is never sent to a server, never stored and never seen by anyone else.

About this content

Written by:
Ferramenta Grátis

Related tools