JPG to Base64 Converter

Drop a JPG or JPEG and get a Base64 data URI you can paste straight into HTML or CSS. Everything runs in your browser — the file is never uploaded.

Drop a JPG here or click to browse
JPG / JPEG files
Preview of the converted JPG
DATA URI
Waiting for a JPG

How to convert a JPG to Base64

Drag a JPG or JPEG onto the drop zone above (or click to browse). The tool reads it locally with the browser's FileReader API and produces a data URI — a string of the form data:image/jpeg;base64,/9j/4AAQSkZJRg… that embeds the whole photo inline. Click Copy, then paste it where you need it. Use the Raw Base64 toggle if you want only the encoded payload without the data: prefix.

Should you inline JPEGs?

Usually not. JPEGs are lossy photographs and tend to be large — far bigger than the icons and small graphics that inlining is meant for. Encoding one as Base64 has real downsides for photos:

Tip: if you only need a low-quality placeholder, re-export the JPEG much smaller (or use a blurred LQIP) before encoding — inlining a multi-hundred-KB photo as Base64 almost always hurts page load.

Using the data URI in HTML and CSS

In HTML, drop it into an <img> src:

<img src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQ..." alt="photo">

In CSS, use it as a background-image:

.hero {
  background-image: url("data:image/jpeg;base64,/9j/4AAQSkZJRgABAQ...");
}

The MIME type for a JPG is always image/jpeg, whether the file ends in .jpg or .jpeg.

Is this private?

Yes. The conversion happens entirely client-side in JavaScript. Your JPG is read into memory in the browser and encoded locally — it is never sent to a server. You can confirm this by opening DevTools → Network: adding a JPG fires no upload request.

Frequently asked questions

Does JPG and JPEG mean the same thing?

Yes. .jpg and .jpeg are the same image format — the three-letter .jpg extension is a relic of old Windows file-name limits. Both use the image/jpeg MIME type, so the Base64 data URI is identical either way.

Should I inline a JPEG as Base64?

Rarely. Because JPEGs are large lossy photos, Base64's ~33% size penalty and lack of separate caching usually make a normal <img src> faster. Inline only tiny thumbnails or placeholders.

What's the MIME type for a JPG data URI?

Always image/jpeg — the data URI begins with data:image/jpeg;base64, regardless of whether the file used the .jpg or .jpeg extension.

How do I go the other way (Base64 back to a JPG)?

Use the Base64 to Image tool to decode a data URI or raw Base64 back into a viewable, downloadable image.

Need text, files, or URL-safe Base64?

The main base64.dev tool handles text, files, and URL-safe mode with auto-detect.

Open base64.dev →