Asistente RD

Image to Base64 converter

Convert a PNG, JPG, GIF, WebP or SVG image to a Base64 data URI inside your browser. Copy the data URI, the <img> snippet or the CSS background in one click.

Free · No sign-up · In your browser

Drop an image here

or

PNG, JPG, GIF, WebP or SVG · up to 20 MB

The image is processed in your browser and never uploaded to any server.

Share on WhatsApp Last reviewed: July 9, 2026

What a Base64 image is (and when it pays off)

Base64 is a way of writing binary data —like the pixels of an image— using only letters, numbers and a handful of symbols. Instead of keeping a separate logo.png file, you get a very long text string that starts with data:image/png;base64, and holds the whole image “dissolved” into characters. That string is called a data URI, and you can paste it straight into your HTML or CSS: the browser rebuilds the image without asking the server for any extra file.

This tool does exactly that conversion. You drop in a PNG, JPG, GIF, WebP or SVG image and, without leaving your browser, it hands you three ready-to-copy outputs: the full data URI, a prebuilt <img> tag and a CSS background-image rule. The image is read with FileReader and never uploaded to any server: everything happens on your own machine.

How to convert an image to Base64

  1. Drop the image onto the upload zone or click “Choose image”. It accepts PNG, JPG, GIF, WebP and SVG up to 20 MB.
  2. The conversion is instant. You will see a preview, the original size, the Base64 size and how many characters the data URI takes.
  3. Copy what you need: the data URI to paste anywhere, the <img> snippet for HTML, or the background-image line for your stylesheet.

Why Base64 is heavier

Base64 packs every 3 bytes of the original file into 4 text characters. That 3→4 ratio makes the text version always take about 33% more space than the raw binary. That is why the trick only pays off with small images: icons, a tiny logo, a repeating pattern. With a big photo, embedding it as Base64 bloats your HTML or CSS and slows the page down.

Original fileOriginal bytesBase64 charactersOverhead
Transparent pixel (1×1 GIF)42 B56+33%
Small icon (PNG)1.20 KB1.63 KB+33%
Medium photo (JPG)150 KB200 KB+33%

Worked example

Take the classic “transparent pixel”, a 1×1 GIF that weighs exactly 42 bytes. When you convert it, its Base64 part is 56 characters:

R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7

The full data URI prepends the data:image/gif;base64, header and comes to 78 characters:

data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7

With that text, the tool gives you the ready HTML snippet:

<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" alt="pixel.gif" />

Let’s check the round trip: if you decode those 56 Base64 characters, you get back exactly the original 42 bytes of the GIF, byte for byte. Nothing is lost in the conversion; only the wrapper changes.

Frequently asked questions

Is my image uploaded to a server?

No. Reading happens with FileReader.readAsDataURL inside your browser, 100% locally. The image never travels over the internet, so you can convert work screenshots, documents or confidential material with complete peace of mind.

When is embedding an image as Base64 a good idea?

When it is small and you want to avoid an extra server request: a button icon, a tiny logo, a background pattern or an HTML newsletter email. For large photos it backfires, because the +33% weight and the fact that the browser cannot cache the data URI separately end up slowing the page down.

Can I go from Base64 back to the original image?

Yes. The process is reversible with no loss: Base64 does not recompress or degrade anything, it just rewrites the same bytes as text. Any Base64 decoder —or pasting the data URI into the browser’s address bar— rebuilds a file identical to the original.

Does it work with SVG?

Yes. An SVG is text, and the tool encodes it the same way into data:image/svg+xml;base64,…. This is very handy for embedding vector icons directly in CSS. For simple SVGs there is also URL encoding, which is often shorter, but Base64 always works and avoids trouble with quotes and special characters.

Why is the data URI so long?

Because it contains the whole image turned into text, plus the header that states the type (data:image/png;base64,). The more bytes the file has, the longer it gets: remember the ratio of 3 bytes for every 4 characters. It is not a bug; it is the expected size.

Related tools