Compress JPG to Base64
Compress a JPG, then convert it to Base64 in one pass — resize, pick the quality, and get a smaller data URI. Base64 always adds ~33% to whatever you feed it, so shrinking the source is the only way to get a smaller string.
100% client-side. Your JPG never leaves your device.
Drop a JPG to compress and encode it
or paste from your clipboard · output stays in your browser
Compress the photo, then encode it
Base64 is an encoding, not a compression method: it rewrites every three bytes as four text characters, so a data URI is always about one third larger than the bytes you feed it. Encoding never shrinks anything. This tool merges the two steps that belong together — compress the JPG, then convert it to Base64 — so you get one usable string instead of a bloated one.
- Add a JPG. Drag it in, pick it, or paste from the clipboard.
- Pick the output format and quality. JPG is the default on this page; WebP usually shrinks the same photo another 25-35% if your target environment supports it.
- Optionally cap the width. An avatar displayed at 64 px does not need 4000 source pixels — downscaling is the biggest single win.
- Copy the result. Full data URI plus ready-to-paste HTML and CSS snippets, with before/after sizes shown.
JPG vs PNG for inline images
Photographs belong in JPG (or WebP): their lossy compression turns a multi-megapixel photo into a few hundred kilobytes, which Base64 then inflates by only that photo's third. PNG stores every pixel losslessly, so a photo-as-PNG produces a data URI several times larger for no visible gain. PNG remains the right pick for flat graphics, screenshots and transparency — that job is covered by the PNG version of this tool.
How much smaller can it get?
Typical numbers: a 1.2 MB camera JPEG capped at 1280 px and re-encoded at 80% quality usually lands between 150 and 300 KB — a data URI of roughly 200-400 KB instead of 1.6 MB. The exact figures depend on the photo, which is why the tool reports the real result rather than an estimate. If you only need the arithmetic for a size you already know, the Base64 image size calculator works from a file size alone.
When to inline at all
A compressed data URI is great for small hero previews, email templates, and anything that must travel inside a single HTML file. For large or reused photos, a normal file is still better: the browser can cache it independently, and a half-megabyte text blob in your HTML hurts parse time. Use the before/after readout to decide with real numbers.
Private by construction
Decoding, resizing, re-encoding and Base64 conversion all happen in your browser through the Canvas and FileReader APIs. The file is never uploaded — you can disconnect from the internet after the page loads and the tool still works.
More Base64 converters
Frequently asked questions
How do I make a Base64 string from a JPG smaller?
Shrink the JPEG before encoding: resize to the displayed dimensions and re-encode at 60-85% quality. Base64 adds roughly 33% to its input, so the source is the only real lever.
Is JPG or PNG better for Base64 encoding?
JPG for photographs — much smaller strings for the same look. PNG for flat graphics and transparency; the PNG version of this tool covers that case.
Does re-encoding a JPG lose quality?
Some, at every re-encode — but at 80%+ quality it is effectively invisible, while below ~50% artifacts appear. The before/after sizes are shown so you can judge with real numbers.
Should I use WebP instead of JPG for inline images?
Often — WebP is ~25-35% smaller at the same quality and keeps transparency. It is one click away in the format selector; keep JPG when older software must decode the result.
Why did my JPG get bigger after compressing?
A lightly-compressed source re-encoded at high quality can grow. Lower the quality, cap the width, or switch to WebP — the tool warns whenever the result is larger than the original.
Is the compression and conversion private?
Yes. Everything runs in your browser with the Canvas and FileReader APIs. The file is never uploaded to any server.