Latch

Image to Base64 encoder

Turn any image into Base64 and copy it as a data URI, a raw string, a CSS rule or an HTML tag.

Your files never leave this device
Encode your image

Drag & drop an image

Any image up to 10 MB · PNG, JPG, WebP, GIF, SVG…

How to convert an image to Base64

Four steps, and it takes a couple of seconds.

1

Add your image

Drag an image onto the box above, or click Browse to pick one from your device.

2

We encode locally

Latch reads the image and encodes it to a Base64 string, which works even offline.

3

Pick a format

Data URI, raw Base64, a CSS background-image rule, or an HTML <img> tag.

4

Copy it

Hit Copy and paste the string straight into your stylesheet, markup or code.

Image to Base64, explained

A Base64 data URI encodes an image's bytes as plain text, so you can drop the picture straight into your HTML, CSS or JavaScript instead of linking to a separate file. It starts with something like data:image/png;base64, and is followed by the encoded data. Because the image travels inside your code, the browser doesn't make a separate network request for it.

Inlining works best for small assets such as icons, tiny logos or an inline SVG, where saving a round-trip matters more than bytes. Size is the downside. Base64 is about 33% larger than the original file, so large photos are usually better left as separate, cacheable files.

Switch the format toggle to grab exactly what you need: a raw string, a ready-made <img> tag, or a CSS background-image rule. Need to go the other way? Base64 to Image decodes a string back into a downloadable picture.

Frequently asked

Is my image uploaded anywhere?

No. Your browser reads and encodes the image locally. Nothing is sent to a server, and the tool keeps working offline once the page has loaded.

What is a Base64 data URI?

A data URI encodes a file's bytes as text, so you can embed an image directly in your HTML, CSS or JavaScript instead of linking to a separate file. It looks like data:image/png;base64, followed by the encoded data.

Why is the Base64 string bigger than my image?

Base64 represents 3 bytes of binary as 4 text characters, so the encoded string is about 33% larger than the original file. You pay that extra size whenever you embed an image inline, so it suits small images like icons. Large photos are usually better left as separate files.

Which image formats can I encode?

Any image your browser can read, including PNG, JPG, WebP, GIF, SVG, AVIF and BMP. The output keeps the original MIME type, so an SVG stays image/svg+xml and a PNG stays image/png.

How do I use the Base64 in CSS or HTML?

Switch the format toggle to CSS for a background-image: url(...) rule, or to HTML for a ready-made <img> tag. Both paste straight into your code and render the image with no extra network request.

Related tools