Logo

JPG to Base64

Encode a JPG or JPEG to Base64 with zero re-compression — free, instant, nothing uploaded

Upload JPG

Drag & drop or click to upload

JPG and JPEG, baseline or progressive

Data URL (full)

Includes the MIME type prefix — paste straight into an HTML or CSS src

Upload a file to see the Base64 output…
Raw Base64

The string only, no prefix — for APIs and databases that add their own header

Upload a file to see the Base64 output…
CSS background-image

A finished CSS rule, ready to paste into a stylesheet

Upload a file to see the Base64 output…
HTML <img> tag

Copy this straight into your markup

Upload a file to see the Base64 output…
Your file never leaves this browser. Nothing is uploaded to a server.

Your Photo Comes Out Exactly As It Went In

You encode a photo, decode it later, and the sky has gone blotchy. Nobody edited it. The converter re-compressed your JPEG on the way through, and JPEG is lossy every single time it is saved. Our JPG to Base64 encoder never re-saves anything.

We read the raw bytes and rewrite them as text. Same file in, same file out, byte for byte.

How to Convert a JPEG to Base64 Properly

  1. Resize to display size. A 4000px photo in a 300px slot is wasted bandwidth.
  2. Strip the metadata. Re-saving through a compressor drops EXIF, including GPS.
  3. Drop the file in. Both .jpg and .jpeg work.
  4. Copy your output. Data URL, raw string, CSS rule, or HTML tag.

Step one does the heavy lifting. Halving the pixel dimensions cuts the file to roughly a quarter, and Base64 multiplies whatever you feed it. Our image compressor handles both the resize and the metadata strip in one pass.

Why JPG to Base64 Gives a Shorter String Than PNG

JPEG throws away detail your eye will not miss, then compresses hard. PNG keeps every pixel exactly. For a photograph, that difference is enormous — often five to twenty times.

Base64 does not compress at all. It just adds roughly a third to whatever you give it. So the format decision is made before encoding, not during.

The flip side is real. JPEG has no transparency and it smears sharp edges, which makes it wrong for logos and screenshots. For those, use the PNG to Base64 converter instead.

The EXIF Problem Nobody Mentions

A photo from a phone carries a hidden payload: GPS coordinates, camera model, lens, exact timestamp, sometimes a thumbnail of an earlier edit.

Because we encode byte for byte, all of it travels inside your Base64 string. That is the honest trade-off of a lossless encoder — you keep everything, including the parts you did not want.

In our experience this is the most common privacy slip we see. Someone pastes a Data URL into a public repo or a support ticket, and the home address goes with it.

The fix takes ten seconds. Re-save the photo through any compressor, which drops metadata by default, then encode the clean copy.

Where an Inline Photo Actually Belongs

Honestly? Almost nowhere. Photos are the worst possible candidate for inlining, and here is why:

  • They are large. Even a well-compressed photo dwarfs the icons Base64 suits.
  • They cannot be cached separately. The browser re-downloads the string with every page.
  • They block rendering in CSS. A heavy stylesheet delays first paint for everyone.

The exceptions we do recommend: email templates where remote images are blocked, single-file HTML reports, and offline documents. We work through the full decision in when inlining images is worth it.

Decoding a JPEG String

Holding an encoded photo and need the file back? The Base64 to JPG decoder rebuilds it and hands you a download.

You do not need the header. Every JPEG payload starts with the characters /9j/, which is enough to identify it on sight.

Working with several formats at once? The general Base64 image decoder detects all of them.

Frequently Asked Questions

Does encoding re-compress my JPEG and lose quality?

+
Not here. We read the file with FileReader and rewrite the same bytes as text, so no pixel is touched. Converters that route your photo through a canvas element do re-compress it, and that second lossy pass is where quality quietly disappears.

Will GPS coordinates from my phone travel inside the string?

+
Yes, and this catches people out. JPEG stores EXIF metadata in the file itself, so location, camera model, and timestamp all ride along in the Base64. Strip the EXIF before encoding if the string is going anywhere public.

Should the MIME type say image/jpg or image/jpeg?

+
Always image/jpeg. There is no registered image/jpg type, even though the file extension is usually .jpg. Some browsers forgive the wrong one, but strict parsers and email clients will not.

My photo appears sideways after I decode it. What went wrong?

+
The EXIF orientation flag. Cameras often save the image rotated and add a tag telling viewers to turn it. Browsers honour that tag for a normal file but frequently ignore it inside a canvas, so rotate the file before encoding.

Is a progressive JPEG still progressive after encoding?

+
It is, because the scan structure lives in the bytes we copy. Whether it helps is another question. Progressive rendering only matters while a file streams in, and an inline Data URL arrives all at once.

Should I resize the photo before converting it?

+
Almost certainly. A 4000-pixel-wide photo displayed in a 300-pixel box wastes enormous bandwidth, and Base64 adds a third on top of that. Resize to the display size first, then encode.

My CMYK JPEG shows up with inverted colours. Why?

+
Browsers only reliably handle RGB JPEGs. CMYK files come out of print workflows and Adobe exports, and support for them is patchy to nonexistent. Convert to sRGB before you encode.

What JPEG quality setting should I use before encoding?

+
We find 75 to 85 is the sweet spot for web use. Below 70 the artefacts start showing on flat areas like skies. Above 90 the file grows fast for a difference almost nobody can see.

How do I remove EXIF data before converting?

+
Re-save the photo through an editor or a compression tool, which drops metadata by default. Our image compressor does this as a side effect. Then encode the cleaned file here.

Why does my screenshot look blurry when I save it as JPEG?

+
JPEG was built for photographs, not for sharp edges. Its compression smears the boundary between text and background, so screenshots pick up a soft halo. Use PNG for anything with text or UI in it.

The Short Version

Resize, strip the metadata, then encode. Converting JPG to Base64 costs no quality here because the file is never re-saved.

Just be honest about whether a photograph belongs inline at all. Most of the time, it does not.

Related Tools You Might Like

Advertisement