Image to Base64

Convert an image to a Base64 data URI — for CSS, HTML, or JSON. Runs locally.

Drop an image here, or click to choose

PNG, JPG, SVG, GIF, WebP — up to 5 MB. Never uploaded.

Image to Base64 converts an image into a Base64-encoded data URI you can embed directly in CSS, HTML, or JSON — no separate file or extra HTTP request. Drop in a PNG, JPG, SVG, GIF, or WebP and copy the data URI, a ready-made CSS background rule, or a complete img tag. The image is read locally and never uploaded.

  • Data URI, CSS background, and <img> tag output
  • Works with PNG, JPG, SVG, GIF and WebP
  • Shows original and Base64-encoded size
  • 100% private — the image never leaves your browser

When to Inline an Image as Base64

Encoding an image as a data URI removes one network request, which is handy for tiny icons, email templates that can't reference external files, and embedding an image inside a JSON payload. The trade-off is size: Base64 is about 33% larger than the binary file and can't be cached separately, so it's best for small assets — large images are usually better served as normal files.

How to Use It

  1. 1Drag an image onto the drop zone, or click to choose a file from your device.
  2. 2The preview, MIME type, and both original and Base64-encoded size appear immediately — nothing is uploaded.
  3. 3Copy the raw data URI, or grab the ready-made CSS background-image rule or HTML <img> tag depending on where you're pasting it.
  4. 4For CSS, paste the rule directly into a class. For HTML, paste the <img> tag as-is — the data URI replaces what would normally be a file path.

Data URI vs a Normal Image File

Data URI (inlined)Normal file (linked)
File size~33% larger (Base64 overhead)Original binary size
HTTP requestsZero — travels with the HTML/CSSOne request per image
Browser cachingNot cached separatelyCached and reused across pages
Best forSmall icons, email, self-contained filesPhotos, large images, anything reused sitewide

Common Uses

  • CSS background iconsInline a small icon as a data URI so it loads with the stylesheet and needs no extra request.
  • Email templatesEmbed images directly where linking to external files is unreliable or blocked.
  • JSON and APIsInclude an image inside a JSON document or API payload as a Base64 string.
  • Self-contained HTMLProduce a single HTML file with images embedded, with no external dependencies.
  • Offline-first appsBundle small images directly into JavaScript or JSON so the app works without a network request for assets.

Frequently Asked Questions

No. The image is read locally with the browser's FileReader and encoded on your device. Nothing is uploaded.

Base64 encoding increases size by roughly 33% compared to the original binary file, which is why it's best for small images.

Any image the browser can read — PNG, JPG/JPEG, SVG, GIF, and WebP. The output data URI keeps the original MIME type.

Yes. The tool gives you a raw data URI plus a ready-to-paste CSS background rule and an HTML img tag.

This tool caps uploads at 5 MB, since Base64 inlining is only practical for small assets — large images should stay as normal linked files that the browser can cache and load progressively.

Mainly to eliminate a network round trip for small, frequently-used assets, or when the destination (an email client, a JSON payload, a single-file HTML export) can't reference an external file at all.

Related Tools