Skip to content
All Tools

Developer JPG · PNG · WebP · SVG · GIF · ICO · BMP 100% local

Image to Base64

Encode an image file as a Base64 string or data URI for embedding.

Runs in your browser — your image never leaves your device Updated September 2026

Processed directly in your browser. Your image never leaves your device.

About this tool

Image to Base64 encodes an entire image file into a printable ASCII string, or into a ready-to-use data URI, so the picture can travel inside HTML, CSS, JSON or email markup without a separate file. It is the encode half of the Base64 round trip: you drop a JPG, PNG, WebP, SVG, GIF, ICO or BMP onto the page, and the tool returns the encoded text together with a size estimate you can use to judge whether inlining it is actually a good idea.

At the byte level, Base64 is a binary-to-text scheme. It re-maps every group of three raw bytes into four printable characters drawn from a fixed 64-character alphabet (uppercase and lowercase letters, the digits 0 through 9, plus the plus and slash symbols), and pads any short final group with equals signs so the output stays a multiple of four. Because each character carries 6 bits of data instead of the 8 bits a byte holds, the encoded text is always about 33 percent larger than the source: a 3 KB icon becomes roughly 4 KB of characters, and a 100 KB image becomes roughly 137 KB of text.

The tool produces two related outputs. The raw Base64 string is the right choice when you are feeding a custom pipeline or an API, since developers frequently carry image bytes as Base64 inside JSON documents, database columns or configuration files. The data URI form prepends the detected MIME type and the marker ;base64, to the same string, yielding something like data:image/png;base64,iVBOR..., which a browser understands natively: paste it into an img src attribute or a CSS url() value and the picture renders without any network request at all.

Where this tool genuinely earns its place is with tiny assets: a one-kilobyte favicon, a small logo mark, a compact SVG glyph or a decorative gradient. Inlining a handful of those can remove several HTTP round trips from a page load, which is why lightweight embedding has a place in performance budgets. For anything larger, the roughly 33 percent overhead, the fact that the browser cannot cache the embedded image separately from the document, and the resulting bloat in the HTML or stylesheet all push the balance back toward a normal file. The on-screen size estimate exists precisely to help you make that judgment before you paste a long string into production code.

Encoding is fully local. The bytes are read in the browser, converted in memory, and the result appears on screen; nothing is transmitted, nothing is written to disk, and closing the tab discards everything. Because the conversion operates on the exact bytes of the file rather than on a re-encoded rendition of its pixels, every piece of embedded metadata survives the trip, which is why the tool does not strip EXIF or other blocks. The practical input ceiling is about 25 MB per file, and that limit guards the browser from the memory spike of constructing a string over 33 MB long from a single upload.

For a complete workflow, pair this tool with its inverse. Encode an asset here, paste the string into a template or commit it to code, and use the Base64 to Image tool whenever you need to recover the original file from an encoded string you received from someone else. The round trip is byte-for-byte lossless: a valid encode followed by a valid decode always returns the exact original file, including headers, color profiles and metadata.

How to use Image to Base64

  1. Drop or select an image file.

  2. Review the encoded string and the file size estimate.

  3. Copy the Base64 string or the full data URI to your clipboard.

What this tool does

  • Base64 output.

  • Data URI format (data:image/…;base64).

  • Copy to clipboard.

  • File size estimate of the encoded string.

Specifications

Input formats JPG, PNG, WebP, SVG, GIF, ICO, BMP
Processing Local browser (Canvas API)
Uploads None — files stay on your device
Max file size 25 MB per file
Original file Never modified
Supported formats JPG, PNG, WebP, SVG, GIF, ICO, BMP
Output formats Raw Base64 string and data URI (data:image/...;base64,...)
Size estimate Reported for the encoded string
Copy support One-click clipboard copy

In-depth Guide

How Base64 encoding works under the hood

The simplest way to picture Base64 is as a packing problem. Binary files use all 8 bits of every byte, but not every byte is printable, and many transports (email bodies, JSON strings, old protocols) only safely carry plain ASCII text. Base64 solves this by changing the unit of work from 8-bit bytes to 6-bit groups; because 3 bytes hold 24 bits and 24 bits divide cleanly into four 6-bit groups, every three input bytes become exactly four output characters.

That fixed 3-to-4 ratio is what makes the expansion predictable. The source length is divided by three, multiplied by four, and rounded up to the nearest multiple of four with padding. The result is always between 133.3 and 133.4 percent of the original binary size, plus whatever transport formatting you add such as line breaks. Nothing about the input content changes the ratio, so the encoded length is fully predictable before you even drop the file in the tool.

  • The output uses only 64 symbols plus the equals-sign padding, so it never contains quotes or spaces that would break an HTML attribute or a JSON string.
  • Each three bytes of input map to four output characters, which makes the encoding reversible with no information loss.
  • Padding up to two equals signs is appended so the output length is always a multiple of four, which decoders rely on.
  • Line breaks are not added by this tool, so the string stays a single uninterrupted value you can copy in one gesture.
Original file size Approx. Base64 length In-text size growth
1 KB 1,368 characters About 1.4 KB of text
10 KB 13,656 characters About 13.7 KB of text
50 KB 68,272 characters About 68.3 KB of text
250 KB 341,336 characters About 341 KB of text
1 MB 1,398,104 characters About 1.4 MB of text
5 MB 6,990,520 characters About 7 MB of text

Raw Base64 versus the complete data URI

A raw Base64 string and a data URI are built from the exact same characters; the only difference is a prefix. The data URI adds the scheme, the MIME type and the encoding marker in front of the payload, turning the string into a self-describing resource that the browser can resolve entirely on its own. The raw string leaves that job to your code: whatever consumes it decides what the bytes mean.

That distinction drives a simple rule of thumb. If the destination is HTML, CSS or an email template, the data URI form is what a browser expects. If the destination is an API, a database, a command-line decoder or your own JavaScript, the raw string is usually cleaner because the prefix would only get in the way. The difference matters more than you might expect: concatenating a data: prefix onto a string that already has one, or scaffolding a decoder around a string that unexpectedly carries the full prefix, are both classic integration bugs.

Property Raw Base64 string Full data URI
Format Plain encoded characters data:[type];base64,... prefix plus payload
Self-describing No; the consumer decides the type Yes; MIME type rides in the prefix
Typical destinations JSON, APIs, databases, scripts, decoders HTML img src, CSS url(), email markup
Length overhead None beyond the 33 percent expansion Expansion plus a 21 to 25 character prefix
Cut and paste Easy; no special characters Easy; prefix makes the intent obvious

Caching, page weight and the real cost of inlining

The hidden cost of an inline image is not the 33 percent expansion; it is the caching behavior. A normal image file is cached by the browser and downloaded once, then reused across every page and every visit until the cache entry expires. A data URI lives inside the HTML or the stylesheet, so it is downloaded again every time the document itself is fetched. On a site with ten pages and one shared inline logo, the same 4 KB logo travels in the markup ten times over.

Page weight compounds the effect. A single 137 KB string is invisible to most browsers, but a page that inlines twenty 50 KB thumbnails carries over a megabyte of text before a single real request. Search engine crawlers, email filters and RSS readers are equally insensitive to embedded images, which is part of why none of them index the content of a data URI image for image search.

This is why the convention holds: inline only what is decorative, small and used once, then let everything else load as a cached file with width, height and lazy-loading attributes.

A practical inlining workflow

The reliable workflow for embedding an image starts before the tool: decide whether the asset is small enough to justify inlining, then drop it in, copy the data URI, and paste it where it belongs. When an asset has to appear on many pages or will change frequently, keep it as a file instead, because a data URI cannot be updated in one place the way a shared file can.

For email, the rule is stricter. Many mainstream email clients strip images that are not hosted, and the ones that render data URIs often do so only after the user clicks to allow remote content. A data URI is a reasonable fallback for a small logo in a newsletter, but a hosted image with a proper alt attribute remains the more dependable default for most campaigns.

  • Check the size estimate the tool shows; if the encoded text would exceed roughly 10 KB, prefer a normal file URL.
  • Copy the data URI form for HTML and CSS, and the raw Base64 form for APIs and code.
  • Use url-encoded SVG data URIs (data:image/svg+xml,%3Csvg...) for very small icons, since they skip the 33 percent Base64 overhead.
  • Verify the string renders by pasting it into a local HTML file before shipping it to production.
  • Re-encode after any change to the source image; an edited image produces different bytes and therefore a different string.

Alternatives to reaching for the encoder

Base64 is one tool among several for removing requests, and it is rarely the most efficient. A CSS sprite combines many small images into a single cached file, an icon font packs dozens of glyphs into one downloaded font, and a modern SVG icon can often be inlined as raw markup, which costs far fewer bytes than its Base64 encoding. Each approach trades different properties: sprites and fonts are cache-friendly, raw inline SVG is editable in the DOM, and a data URI is self-contained but uncacheable.

The guidelines below keep the choice simple. The theme is consistent: reserve inline encoding for assets that are genuinely tiny, genuinely one-off and genuinely hard to source any other way.

Approach Cache friendly Best suited for
External file Yes, fully cached Anything large, reused or frequently updated
Data URI (Base64) No, travels with the document One-off assets under a few KB
CSS sprite Yes, one cached file Many small graphics used across a site
Inline SVG markup No, but tiny Icons and simple graphics you want editable
Icon font Yes, one cached font Large icon sets with similar styling

How it works

Base64 encoding

The tool reads the image bytes in the browser and encodes them using the Base64 alphabet (A-Z, a-z, 0-9, +, /) with = padding. Each 3 bytes of input produce 4 characters of output, adding roughly 33% to the file size.

Data URI format

A data URI prepends the MIME type and encoding declaration to the Base64 string: data:image/png;base64,iVBOR.... Browsers that support data URIs can render the image directly from the markup without an HTTP request.

Example result

Before After
Input file: icon.png (3.2 KB)
Raw file size: 3,200 bytes
Base64 output length: 4,272 characters
Estimated encoded size: 4,272 bytes (~33% larger)
Round-trip: Decode with the Base64 to Image tool to recover the original

Size and output length depend on the input. The example uses a small icon.

Pro tips

Set a hard threshold before you start

Decide in advance that assets over a few kilobytes stay as files. The 33 percent tax plus lost caching only pays off for very small, single-use images.

Prefer url-encoded SVG over Base64 for icons

An SVG is text to begin with, so percent-encoding it (data:image/svg+xml,%3Csvg...) produces a much shorter string than Base64 at identical pixels.

Read the size estimate before copying

The tool shows the projected encoded length for a reason; a number in the hundreds of kilobytes is a signal to stop and use a regular file URL instead.

Keep repeated images out of the markup

A logo that appears on every page should be a cached file, not a data URI that redownloads with each document.

Remember metadata travels with the bytes

Encoding does not clean the file. If an image must not carry EXIF or GPS, strip metadata first and encode the cleaned copy.

Test email rendering before relying on it

Client support for inline images varies widely; send a test message and confirm the image actually appears before committing to the approach.

When to use it

Great for Image to Base64

  • Inlining tiny assets like icons, logos, or decorative elements directly in HTML to eliminate an extra HTTP request.
  • Embedding images in CSS background-image values for a single-file delivery.
  • Including images in email HTML where external hosting is unreliable or blocked by CSP.
  • Generating test data for CSP (Content Security Policy) inline image rules.

Watch out for

  • Do not Base64-encode large images. The 33% size increase bloats HTML and prevents browser caching. A normal file load is faster for anything over a few KB.
  • Do not use Base64 for images that change frequently. The encoded string is baked into the markup and cannot be cached independently like a file URL.

Privacy

This tool runs entirely in your browser using the Canvas API. Your image is never transmitted — there is no upload endpoint involved. Clearing the page removes the file from memory.

The image is read and encoded in the browser. The resulting string is never transmitted externally. Close the tab or reload the page to clear it from memory.

Edits never overwrite your original file. Every result is a new download, so you always keep the source image. Read the privacy policy.

Troubleshooting

Base64 uses 6 bits per character instead of 8, which expands the data by roughly 33%. This is the inherent cost of representing binary data as ASCII text.

No. The encoding operates on the raw file bytes, so all metadata embedded in the file is preserved in the encoded output.

Yes. A correct Base64 decode restores the original bytes. Use the Base64 to Image tool to verify a round-trip.

Frequently asked questions

Mainly for tiny decor-free images inline in HTML/CSS. For anything large, a normal file load is faster.

It is generated locally and never sent anywhere.

The tool will not process it. Base64-encoding a 25 MB file produces roughly 33 MB of text, which is impractical to embed in markup anyway.

Use the data URI format (with the data:image/...;base64, prefix) for embedding in HTML src attributes or CSS url() values. Use the raw Base64 string if you need just the encoded text for a custom pipeline or API.

No. Base64 operates on the exact bytes of the file, so whatever the file contained, including EXIF, GPS, color profiles and embedded thumbnails, survives into the encoded string unchanged. Clean the file first if removing metadata is part of the goal.

Encoding a 25 MB file produces a string of about 33 million characters, all held in browser memory at once. The ceiling keeps a single encode manageable on phones and modest laptops, and it is already far beyond the size where inlining makes sense.

Yes. Base64 is a lossless, fully reversible encoding. Feeding the exact string to a conforming decoder, or to the Base64 to Image tool, reproduces the original file byte for byte.

Effectively no. Crawlers treat embedded images as part of the document markup rather than as individual image resources, so a data URI does not participate in image search the way a hosted file with a URL does.

Neither leaves your device. The file is converted to a string in browser memory, displayed on screen, and discarded when you close or reload the tab; there is no upload step anywhere in the flow.

Yes. A policy that blocks inline content may refuse data URIs unless the relevant directive (such as img-src or media-src) explicitly allows data. Check the site CSP when an embedded image fails to render.

Technical details

Base64 alphabet A-Z, a-z, 0-9, +, / with = padding
Expansion ratio 33% (3 input bytes produce 4 output characters)
Data URI prefix data:image/<type>;base64,
Character encoding ASCII output, safe for HTML and CSS embedding

Tool last updated: September 2026. Browse all image tools.