Convert JPG/JPEG to Base64
JPEG (Joint Photographic Experts Group) is the most common image format on the web, used for photographs and complex images where lossy compression produces acceptable quality at small file sizes. This tool converts any JPG/JPEG file to a Base64 string for embedding in code.
How to Use
- Drop a JPG file onto the upload area or click to browse your files
- The tool reads the file locally and encodes it to Base64
- Pick an output format: plain Base64, data URI, or CSS background
- Copy the result
JPEG Specific Considerations
File size and Base64 length
JPEG files are already compressed. A typical photograph might be 200-800 KB depending on resolution and quality settings. After Base64 encoding, that becomes 267 KB to 1.07 MB of text. This is important context for deciding whether to inline the image or serve it separately.
MIME type
The correct MIME type for JPEG is image/jpeg, not image/jpg. This tool automatically sets the MIME type from the file, so data URIs always use the correct data:image/jpeg;base64,... prefix. Some systems accept image/jpg as an alias, but image/jpeg is the IANA-registered type.
EXIF data
JPEG files can contain EXIF metadata: camera model, GPS coordinates, orientation, timestamps. Base64 encoding preserves all of this because it encodes the complete file bytes. If you need to strip EXIF before sharing (for privacy), do that before encoding. The HTML <canvas> trick (drawing the image to canvas and exporting) strips EXIF but also re-encodes the JPEG, changing quality.
Common Use Cases for Base64 JPEGs
Email templates
Email clients block external images by default. Embedding a small logo or header image as a Base64 data URI ensures it renders immediately. Keep it under 10 KB. Gmail clips emails larger than 102 KB, and Base64 images count toward that limit.
API payloads
REST APIs that accept image uploads often support Base64 encoded bodies as an alternative to multipart form data. This simplifies the request from the client side:
{
"image": "/9j/4AAQSkZJRgABAQ...",
"filename": "photo.jpg"
}
Server rendered HTML
When generating HTML on the server (PDF generation, email rendering, single file exports), Base64 data URIs let you produce a self contained document without managing image file references.
Performance Tradeoffs
JPEG compression ratios mean the resulting Base64 string can be large. For web pages:
- Under 5 KB: inline freely. The HTTP request overhead exceeds the Base64 penalty.
- 5-20 KB: consider inlining for critical above the fold images to avoid render blocking.
- Over 20 KB: serve as a separate file with proper caching, CDN, and lazy loading.
For the reverse operation, Base64 to Image decodes Base64 strings back to downloadable images. For other image formats, see PNG to Base64, SVG to Base64, or the general Image to Base64 converter.