Image to Base64

Encode any image as a base64 data URL.

Sometimes an image needs to travel as text, not as a separate file — embedded directly inside CSS, HTML or a JSON payload. This tool converts your image into a Base64-encoded string that does exactly that.

Solving the "one image, one extra request" problem

Every separate image file referenced by a webpage traditionally requires its own individual HTTP request, and for years, minimizing the total number of requests was a significant web performance concern (before HTTP/2's multiplexing, introduced around 2015, made multiple simultaneous requests over one connection considerably cheaper). Base64-encoding small images and embedding them directly inline — as a "data URI" right within the HTML or CSS — was a widely used technique specifically to eliminate that extra request entirely for small, frequently-used graphics like icons, at the cost of a roughly 33% larger encoded payload compared to the original binary file.

How the conversion works

The tool reads your image's raw binary data and encodes it using the standard Base64 algorithm (defined in RFC 4648), representing every 3 bytes of the original image as 4 text characters drawn from a 64-character alphabet — producing a text string that can be embedded directly wherever binary data isn't safely representable, such as within a CSS background-image: url(data:image/png;base64,...) declaration or a JSON API payload.

Where converting an image to Base64 is genuinely useful

  • Embedding small icons directly in CSS — inlining a small, frequently reused icon as a data URI avoids a separate network request, which can still meaningfully help performance for very small, critical assets even in the HTTP/2 era.
  • Including images in JSON API payloads — since JSON is a text-only format with no native way to represent binary data, Base64 encoding is the standard technique for embedding an image directly within an API response or request body.
  • Storing small images directly in a database field — some applications store small profile pictures or thumbnails as Base64 text directly in a database column rather than managing separate file storage.
  • Email HTML with embedded images — certain email clients and templates use Base64-embedded images to ensure graphics display reliably without depending on external image loading, which some email clients block by default.

Frequently asked questions

Does Base64 encoding make my image file larger? Yes, by design — encoding binary data as text using only 64 safe characters requires about 33% more space than the original binary file, a deliberate and unavoidable tradeoff for guaranteeing the data is safely embeddable as plain text.

Is Base64-encoding an image the same as compressing it? No, they're unrelated — Base64 is purely a re-encoding technique for safe text embedding and actually increases file size rather than reducing it; if you want a smaller file, you need separate image compression, applied either before or independently of the Base64 encoding step.

Should I always inline images as Base64 instead of using separate files? No — this technique works best for small, frequently reused graphics like icons; larger images generally benefit more from being served as separate, cacheable files, since a Base64-embedded image can't be cached independently by the browser the way a standalone image file can.

Further reading