How to use
- Drop a .jpg or .jpeg file onto the drop area, click to choose one, or paste an image.
- To keep the file exactly as it is, leave conversion off. To shrink it, choose JPEG or WebP and lower the quality.
- Set a maximum width if the photo is larger than it will be displayed.
- Copy the output you need, such as the img tag for a page or raw Base64 for an API, or download it as a file.
JPEG in brief
JPEG is the standard format for photographs. It uses lossy compression, discarding detail the eye barely notices, and it has no transparency. Files end in .jpg, .jpeg or sometimes .jfif, but the MIME type is always image/jpeg; image/jpg is not a registered type, even though many browsers tolerate it. A JPEG data URI starts with data:image/jpeg;base64,/9j/, the encoded start-of-image marker.
Shrinking a photo before encoding
Photos are where Base64 hurts most: a 200 KB JPEG becomes about 270 KB of text. Two settings make the biggest difference:
- Maximum width. Halving the width cuts the pixel count to a quarter. A phone photo 4000 pixels wide is rarely needed at that size.
- Quality. Values around 70 to 80% usually look the same as the original on screen and are much smaller. Very low values show blocky artefacts.
Converting to WebP at a similar quality is often smaller still. Watch the encoded size shown for each setting and keep the smallest result that still looks right.
EXIF metadata
Photos from cameras and phones carry EXIF metadata: camera model, date and time, and sometimes GPS coordinates. Without conversion, the Base64 output contains the original bytes, metadata included, and anyone who decodes it can read them. That is what you want when the exact file matters, for example when an API checks a hash or reads the capture date.
Converting re-encodes the pixels in the browser, and EXIF data is not carried over. The output is smaller and no longer reveals where the photo was taken.
Where a JPEG data URI is worth it
Good fits are tiny blurred placeholders (an image 20 to 40 pixels wide, inlined while the full photo loads lazily), thumbnails in JSON responses and single-file HTML exports. Hero images and galleries belong in separate files that the browser can cache.
# Python
import base64
with open('photo.jpg', 'rb') as f:
uri = 'data:image/jpeg;base64,' + base64.b64encode(f.read()).decode('ascii')
Frequently asked questions
Is JPG the same as JPEG?
Yes. The shorter .jpg extension dates from systems that allowed only three characters. Both are the same format with the MIME type image/jpeg.
Does Base64 encoding reduce JPEG quality?
No. Base64 is a lossless representation of the file bytes. Quality changes only if you choose a conversion, which re-encodes the image with the quality you set.
Can a JPEG data URI have a transparent background?
Does the Base64 string contain the location of my photo?
It can. If the original JPEG has GPS data in its EXIF metadata and you encode it unchanged, the location is in the string. Converting the image removes EXIF metadata.