Base64 Image Encoder

Drop your image here

Processing...

Inlining a small image as a Base64 data URI can avoid one HTTP request and keeps the asset with the HTML or CSS that uses it. This browser tool accepts validated PNG, JPEG, GIF and WebP files plus SVG text that parses with an <svg> root, up to 5 MiB. It generates raw Base64, data URI, CSS, HTML or JSON output. Check that the chosen output fits the destination. SVG receives a structural check only and may still contain active or unsafe content.

How to encode an image

  1. 1

    Drop your image

    Choose a PNG, JPG, GIF, WebP or SVG up to 5 MiB. A raster image may be no more than 16,384 pixels on either edge and 33,554,432 pixels in total. The encoded text stays below 7 MiB.

  2. 2

    Encoding runs in the browser

    Image bytes are read, Base64-encoded and prefixed with the correct `data:` URI header.

  3. 3

    Choose output format

    Raw Base64, CSS `background-image` rule, HTML `<img>` tag, or JSON-safe string.

  4. 4

    Copy the result

    Paste into a stylesheet, template, or API body.

When inlining images is worth it

Candidates to evaluate and test before inlining:

  • Icons under 2 KB, Saves an HTTP request with negligible overhead.
  • Email templates - Data URIs are not supported consistently by email clients. Test your target clients and use CID or hosted images when needed.
  • Hero placeholders (LQIP), Low-quality blurred version inline, full image loaded after.
  • SVGs used once, SVG is text, so a properly percent-encoded data URI can be smaller than Base64 depending on its characters and formatting.

Bad candidates:

  • Large images, Inflating by 33% for a 500 KB image is 166 KB of waste.
  • Images reused across pages, Inlining disables browser caching across routes.
  • Critical CSS, Inlining heavy images blows up the critical path.

Size expectations

Image size Base64 string size
500 bytes ~680 chars
2 KB ~2.7 KB
20 KB ~27 KB
200 KB ~270 KB

Data URI format

data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwAEhQGAhKmMIQAAAABJRU5ErkJggg==
  • data: scheme
  • MIME type
  • ;base64, indicator
  • The encoded bytes

SVG is a special case

Base64 expands the original SVG bytes by roughly one third before surrounding syntax, while percent-encoding adds overhead only to characters that need escaping. Which representation is shorter depends on the SVG. A text form should use a properly percent-encoded data:image/svg+xml,... value; the bare ;utf8 token is not a standard data-URL parameter, and raw #, %, quotes or whitespace can break the URL. This tool checks SVG structure but does not sanitize scripts, event handlers or external references, so review untrusted SVG before using the output.

Frequently Asked Questions

Base64 text is roughly 4/3 the source byte size, plus the data URI or wrapper. Whether inlining is faster depends on request multiplexing, compression, caching, reuse, bundle size and content-security policy. Measure the actual page; there is no universal 4 KB cutoff.

Inlining alone has no guaranteed SEO effect. A CSS background has no image alternative-text semantics, so use an HTML <img> with meaningful alt text when the image conveys information. Keep decorative backgrounds out of the content structure.

No. The encoder reads the file locally with the FileReader API and produces the Base64 string in-browser. Nothing leaves your machine.

Yes, use the Base64 to Image tool to turn a data:image/... URI back into a downloadable file.

Related Tools