JPG Content Type - What Is the Correct MIME Type?
The correct content type for JPG files is
image/jpeg. Not image/jpg. Not image/JPG. Always use image/jpeg in your HTML, server configuration, and APIs.
This guide explains everything you need to know about JPG content type. You will learn the correct MIME type, how to configure it on different servers, common mistakes to avoid, and how to troubleshoot header errors.
If you have ever built a website or worked with web servers, you have likely encountered MIME types. They tell browsers what kind of file they are receiving. Getting them wrong can cause images not to display, or files to download instead of showing in the browser.
Let us clear up the confusion once and for all.
Let us clear up the confusion once and for all.
What is a MIME Type?
MIME stands for Multipurpose Internet Mail Extensions. It was originally created for email attachments but is now used everywhere on the web.
A MIME type tells the browser or client what kind of file it is receiving. It has two parts: a type and a subtype, separated by a slash. For example:
A MIME type tells the browser or client what kind of file it is receiving. It has two parts: a type and a subtype, separated by a slash. For example:
text/html– HTML documentimage/jpeg– JPEG imageapplication/pdf– PDF document
When your web server sends a file, it includes a
Content-Type header with the correct MIME type. If the MIME type is wrong, the browser might display the file incorrectly or offer it as a download.What is the content type for JPG?
The correct content type for JPG files is
This is the official MIME type registered with IANA (Internet Assigned Numbers Authority). It applies to both .jpg and .jpeg file extensions. The MIME type does not change based on the file extension.
When your web server sends a JPG image, it should include this header:
image/jpeg. This is the official MIME type registered with IANA (Internet Assigned Numbers Authority). It applies to both .jpg and .jpeg file extensions. The MIME type does not change based on the file extension.
When your web server sends a JPG image, it should include this header:
Content-Type: image/jpeg
This tells the browser "this is a JPEG image" regardless of whether the file is named image.jpg or image.jpeg.
Is TIF or JPG better quality?
This is a common question, but it is separate from MIME types. For quality comparison:
- TIF (TIFF): Lossless format, preserves every detail. Files are very large. Used for professional photography, printing, and archiving.
- JPG (JPEG): Lossy format, compresses files by discarding some data. Much smaller files, excellent for web and everyday use.
For archiving precious photos, TIFF is better quality. For sharing online and everyday use, JPG is the practical choice.
For more details, read our guide on best file type for scanning photos for high quality.
For more details, read our guide on best file type for scanning photos for high quality.
What is the file type of JPG?
JPG is a file format for images. It stands for Joint Photographic Experts Group, the committee that created the standard.
The file extension can be either
The MIME type for both is
The file extension can be either
.jpg or .jpeg. There is no difference between them—they are the same format. The only reason for two extensions is historical: early Windows systems required three-letter extensions, so .jpg became common. The MIME type for both is
image/jpeg.What is the content of a JPEG file?
A JPEG file contains compressed image data using the JPEG compression algorithm. It stores:
- Image pixels in YCbCr color space (converted from RGB)
- Metadata like EXIF data (camera settings, date, location)
- Optional thumbnails
- Color profiles (ICC)
- Comments and other metadata
The file structure includes markers that identify different sections, making it possible for software to read and display the image correctly.
JPG vs JPEG MIME Type | Clearing the confusion
Many developers mistakenly use
image/jpg as the MIME type. This is incorrect. The correct type is always image/jpeg.For a complete guide on this topic, read JPG vs JPEG MIME type.
How to set the correct JPG content type in HTML
In HTML, you do not directly set the MIME type for images. The server handles this. However, when using the
<picture> element, you specify the type attribute:<picture> <source srcset="image.avif"
type="image/avif"> <source srcset="image.webp"
type="image/webp"> <img src="image.jpg"
alt="Description"> </picture>
Notice that for JPG fallback, we do not specify a type—the browser will use its default handling. But if you were to specify, it would be
type="image/jpeg".How to set the correct JPG content type on servers
Apache
In your .htaccess file or Apache configuration:
AddType image/jpeg .jpg .jpeg .jpe
Nginx
In your mime.types file or nginx.conf:
types {
image/jpeg jpg jpeg jpe;
}
IIS (Internet Information Services)
In your web.config file:
<staticContent> <mimeMap fileExtension=".jpg"
mimeType="image/jpeg" /> <mimeMap fileExtension=".jpeg"
mimeType="image/jpeg" /> <mimeMap fileExtension=".jpe"
mimeType="image/jpeg" /> </staticContent>
How to set the correct JPG content type in APIs
Node.js / Express
res.setHeader('Content-Type',
'image/jpeg');
res.sendFile('image.jpg');
Python / Flask
from flask import send_file
response = send_file('image.jpg',
mimetype='image/jpeg')
PHP
header('Content-Type:
image/jpeg');
readfile('image.jpg');
Java / Spring
@RequestMapping(value = "/image",
produces = MediaType.IMAGE_JPEG_VALUE) public @ResponseBody byte[] getImage() { // return image bytes }
Common JPG content type errors and how to fix them
Error: Image downloads instead of displaying in browser
This usually happens when the server sends the wrong Content-Type header. Instead of
Fix: Configure your server to send the correct MIME type as shown above.
image/jpeg, it might be sending application/octet-stream or no header at all. Fix: Configure your server to send the correct MIME type as shown above.
Error: "image/jpg" used instead of "image/jpeg"
Some servers or applications use
Fix: Update your configuration to use the correct
image/jpg by mistake. While some browsers may still display the image, it is technically incorrect and may cause issues in some contexts. Fix: Update your configuration to use the correct
image/jpeg type.Error: Mixed content warnings
If your page is served over HTTPS but the image is served over HTTP, browsers may block it. This is not a MIME type issue but a security one.
Fix: Ensure all images are served over HTTPS.
Fix: Ensure all images are served over HTTPS.
Error: Incorrect MIME type in HTML5 canvas
When working with canvas and toDataURL(), you might need to specify the MIME type:
const dataURL = canvas.toDataURL
('image/jpeg', 0.9);
How to check the content type of a JPG file
You can check what content type your server is sending using browser developer tools:
- Open browser DevTools (F12)
- Go to the Network tab
- Reload the page
- Click on the image file
- Look for "Content-Type" in the response headers
You can also use command-line tools like
curl:curl -I https://example.com/image.jpg
Look for the
Content-Type header in the response.MIME types for other common image formats
For reference, here are the correct MIME types for other formats:
JPG vs JPEG XL | What about newer formats?
JPEG XL is a newer format that offers better compression and modern features. Its MIME type is
image/jxl. For a detailed comparison, read JPG vs JPEG XL.Why correct MIME types matter
Using the correct MIME type is important for several reasons:
- Correct display 📌 Browsers rely on MIME types to know how to handle files. An image with the wrong MIME type might not display at all.
- Security 📌 Incorrect MIME types can lead to security issues. For example, if a server sends HTML as
image/jpeg, it might bypass security filters. - SEO 📌 Search engines use MIME types to understand content. Incorrect types can affect indexing.
- User experience 📌 Files open correctly instead of downloading unexpectedly.
Common questions about JPG content type
Is it image/jpg or image/jpeg?
Always use
image/jpeg. image/jpg is not a registered MIME type and may not be recognized by all systems.Should I use uppercase or lowercase?
Always use lowercase. MIME types are case-sensitive and the standard is lowercase.
What about .jpe extensions?
The .jpe extension is also used for JPEG files. The MIME type is still
image/jpeg.Can I use image/jpg in HTML5?
You should not. While some browsers may accept it, it is not standards-compliant. Always use
image/jpeg.Remember: JPG and JPEG are the same format. The correct MIME type for both is
image/jpeg. Always lowercase.
The bottom line on JPG content type
The correct content type for JPG files is
Configure your server correctly, use the right MIME type in your APIs, and you will avoid common errors that cause images not to display.
For more help with image formats and conversion, visit Image Converter 24.
image/jpeg. This applies to all JPEG files regardless of whether they use .jpg, .jpeg, or .jpe extensions. Configure your server correctly, use the right MIME type in your APIs, and you will avoid common errors that cause images not to display.
For more help with image formats and conversion, visit Image Converter 24.
Summary: The correct MIME type for JPG files is
image/jpeg. Not image/jpg. Configure your server with AddType image/jpeg .jpg .jpeg .jpe (Apache) or the equivalent for your platform. Always use lowercase. This ensures your images display correctly in all browsers.