Skip to main content

Image Tools

Image to Base64

Convert images to Base64 encoded strings. Free online tool — no upload, no sign-up, runs entirely in your browser.

See how to use this tool

Image to Base64

Convert an image into a Data URI for HTML or CSS.

About Image to Base64

ToolConv's image-to-base64 converter encodes any image into a data URI you can paste directly into HTML, CSS, or JavaScript — eliminating an extra HTTP request for small icons, background patterns, or email-embedded images. It supports JPG, PNG, WebP, GIF, and SVG inputs, and outputs a clean `data:image/png;base64,...` string, a CSS `background-image: url(...)` rule, or an `<img src>` tag depending on what you need.

Encoding is purely a browser operation using FileReader.readAsDataURL — nothing is uploaded, so you can inline confidential diagrams or unreleased UI mocks into a prototype without any leakage. The tool also reports the encoded size, the size overhead versus the binary file, and warns you when a data URI is larger than ~4KB, since inlining very large images hurts performance more than it helps.

How to use it

  1. 1Upload the image you want to inline.
  2. 2Pick an output format: raw base64, data URI, CSS rule, or <img> tag.
  3. 3Check the encoded length and the overhead warning, if any.
  4. 4Click Copy to put the full string on your clipboard.
  5. 5Paste into your HTML/CSS/JS or email template.

When to use it

  • ✓Inlining a 2KB logo PNG as a data URI to cut a render-blocking request on a landing page.
  • ✓Embedding a background pattern into a CSS file so a single HTML email is fully self-contained.
  • ✓Bundling small UI icons into a single SVG sprite or base64 block for a prototype.
  • ✓Passing an image to a JS library that only accepts a data URI input.

Features

  • •Accepts JPG, PNG, WebP, GIF, and SVG inputs.
  • •Four output modes: raw base64, data URI, CSS rule, <img> tag.
  • •Reports encoded size and base64 overhead (roughly +33%).
  • •Warns when a data URI exceeds 4KB, since large inlines hurt performance.

Related tools

FAQ

Are my images uploaded for encoding?

No. Encoding uses the browser's FileReader.readAsDataURL API entirely on-device. You can inline confidential diagrams or unreleased UI mocks without anything leaving your browser.

Why is the base64 string about a third larger than the file?

Base64 encodes every 3 bytes as 4 ASCII characters, a fixed ~33% overhead. This is inherent to the encoding, not a bug — the tradeoff is that the string is HTTP-request-free.

Should I inline all my images as base64?

No. Inlining is only worth it for files under ~4KB that block first paint. Larger images bloat HTML/CSS, defeat browser caching, and can't be served from a CDN — keep them as separate files.

Can I embed base64 images in HTML emails?

Support is spotty — Gmail strips most data URIs, Outlook desktop blocks them entirely. Base64 works reliably in internal tools and prototypes, but for external email you should host the image and link to it.

Does it work on SVG files?

Yes. SVGs are encoded as `data:image/svg+xml;base64,...` (or URL-encoded). Because SVG is already text, inlining the raw SVG markup is often smaller than base64-encoding it.

Is there a file size limit?

Yes, 10MB. Beyond that the base64 string becomes unwieldy and the performance penalty of inlining is severe — use image-compress first, or host the file separately.