VIP pricing

← All tools

Image to Base64

Turn an image into Base64 text you can paste straight into HTML / CSS / Markdown, in five output formats; the conversion happens entirely on this device and images are never uploaded.

Drag images here or click to choose
Multi-select supported · JPG / PNG / WebP / GIF / BMP
ⓘ
The resulting string contains the whole image in plain form.Posting a Data URI publicly is the same as publishing the original image. Be careful with images that contain private content.
Base64 encoding only, no re-compression: pixels and format stay exactly as they were. Base64 is plain text about 1.33× the original size.

How to use

  1. Drop in images, or click to choose (batch supported)
  2. Pick an output format: Data URI, raw Base64, CSS, img tag or Markdown
  3. Copy each result, or use Download all to get a ZIP

FAQ

Does Base64 make files bigger?
Yes — the text is about 1.33× the original size, and embedding an image over 2 MB makes a page noticeably heavier.

Is the output safe to share?
The string contains the whole image in plain form; posting it publicly is the same as publishing the original.

Everything runs locally in your browser — files are never uploaded. BoxKit VIP unlocks unlimited use of all 29 tools.

When to use it

For things from a few hundred bytes to a few KB — icons, dividers, loading animations — an external link is actually slower: the browser has to parse the HTML, discover the address, then go through DNS, connection and handshake, and finally fetch an image of a few hundred bytes, of which the image is only a small part and the rest is fixed overhead. As a Data URI the characters arrive together with the HTML, so rendering does not wait on the network again.

It also suits single-file distribution: offline HTML reports, demos sent to others, intranet pages that cannot reach an external CDN — after inlining you never get a page of broken images because one folder was not copied.

Conversely, article illustrations, product images, thumbnails, avatars and logos should not be inlined: they repeat across pages, need their own cache, and need a separate address so image search can index them. One question decides it: will this image be used again somewhere else? If yes, link it externally.

How to choose the settings

Compared with other approaches

Inlining saves one request and one round trip only on the first visit, at the cost of making the image part of the HTML or CSS: the browser does not cache it separately, so it is re-downloaded every time the page loads and the text is retransmitted with it. External images have their own cache and 304 checks, so repeat visits cost almost nothing. Under HTTP/2 and HTTP/3 several images already share one connection, so saving requests is worth much less than in the HTTP/1.1 era, and it is only still noticeable on high-latency networks.

Compared with sprite sheets, both save requests. With fewer than five or six icons, inlining is easier and needs no coordinate bookkeeping; beyond that, a sprite sheet or icon font is better because swapping an image does not touch the whole block of text. SVG icons do not actually need Base64: SVG is already text, inlining it directly inherits currentColor and lets CSS recolour it, whereas converting to Base64 throws that advantage away and is only worth it when it has to go into a CSS background-image.

Compared with other online conversion services, the difference is where the file goes: those sites upload the image to a server to encode it, the original lands on someone else's machine, and the page is stuffed with ads; this tool reads the file with the browser (FileReader), the image never leaves this device, it works offline, and images with private content can be dragged in directly. Its weak points should be stated too: it only encodes, it does not compress or resize, so the output size depends entirely on the original; over 2 MB it only warns, it does not block; and it does not decide for you whether to inline or link externally.

Additional Q&A

How is the 1.33× ratio calculated?
Base64 cuts every 3 bytes (24 bits) into four 6-bit groups, each mapping to one of 64 printable characters. 3 bytes become 4 characters, a ratio of 4 divided by 3, about 1.33. When the original length is not a multiple of 3, one or two equals signs are added at the end, so you often see = or == at the tail; it is only padding.

Why does inlining a large image slow down the first screen?
HTML and CSS block rendering: the browser has to finish parsing before it starts painting. A 500 KB image becomes about 670 KB of text packed into the HTML, and the first screen waits that much longer; that text also has to download completely before it can be decoded, unlike an external image, which can display while it downloads. Enabling gzip on the server recovers part of it, but the compressed result is still never smaller than the original binary.

What are the common reasons an image pasted into Markdown or CSS does not display?
Wrap the img src in double quotes for safety, since the character set contains no quotes; CSS url(...) must be quoted because the string contains plus signs, slashes and equals signs; Markdown wraps the address in parentheses, and square brackets and parentheses in the alt text must be escaped, with the whole syntax on one line. Also, many Markdown renderers and CMSs filter data: addresses, so a pasted image breaks.

In which cases should you absolutely not use inlining?
Large images (over 10 KB is worth thinking twice about, and phone photos are out of the question); many images on one page; logos, avatars and covers that need to be reused across pages; images that depend on their own address for image search, which lose it once inlined; and images that people should be able to right-click and save or put in an email, which most mail clients block.