JPG MIME Type | What Is the Correct Content Type

il y a 2 jours 29

JPG MIME Type | What Is the Correct Content Type?

The correct MIME type for JPG files is image/jpeg. Not image/jpg. Not image/JPG. Always use image/jpeg in your HTML, server configuration, and HTTP headers.
 
jpg mime type, mime type for jpg, image jpeg mime type, correct mime type for jpg, image/jpg vs image/jpeg, http content type jpg, jpg content type header, mime type for jpeg images
 
This guide explains everything you need to know about JPG MIME type. You will learn what MIME types are, the correct type for JPG, common mistakes to avoid, and how to configure it properly.
 
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, files to download instead of showing, or even security issues.

Let us clear up the confusion about JPG MIME types 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:
  • text/html – HTML document
  • image/jpeg – JPEG image
  • application/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 MIME type for JPG?

The correct MIME type for JPG files is image/jpeg.

This is the official MIME type registered with IANA (Internet Assigned Numbers Authority). It applies to files with .jpg, .jpeg, and .jpe 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 jpg a MIME type?

No, "jpg" by itself is not a MIME type. MIME types always have a type and subtype format like image/jpeg.

The correct MIME type for JPG files is image/jpeg. Some people mistakenly use image/jpg, but this is not a registered MIME type and should be avoided.

For more details, read our guide on is image/jpg a valid MIME type.
 

What is the difference between image/jpeg and image/jpg?

image/jpeg is the correct, registered MIME type. image/jpg is not a registered MIME type and is technically invalid.

While some browsers may still display images with image/jpg due to lenient error handling, it is not guaranteed to work everywhere. Always use image/jpeg for maximum compatibility.

For a complete comparison, see JPG vs JPEG MIME type.
 

What are the three types of Mime?

MIME types are not limited to three types. They are organized into categories called "top-level media types." The main categories are:
  • application: Application-specific files (PDF, JSON, XML, etc.)
  • audio: Audio files (MP3, WAV, etc.)
  • image: Image files (JPEG, PNG, GIF, etc.)
  • text: Text files (HTML, CSS, plain text, etc.)
  • video: Video files (MP4, AVI, etc.)
  • multipart: Multipart documents (form data, etc.)
Each category contains many specific MIME types. For images, the correct type for JPG is image/jpeg.
 

Is JPEG lossy or lossless?

JPEG is a lossy format. It achieves smaller file sizes by discarding some image data that the human eye is less likely to notice.

At high quality settings (90-100%), the loss is invisible to most viewers. But every time you save a JPEG, you lose a little more quality.

For lossless images, use PNG, TIFF, or lossless JPEG 2000.
 

What is the MIME type of a PNG?

The correct MIME type for PNG files is image/png.

Like JPEG, PNG uses the image/ top-level type with its specific subtype. Other common image MIME types include:
Format File Extensions MIME Type
JPEG / JPG .jpg, .jpeg, .jpe image/jpeg
PNG .png image/png
GIF .gif image/gif
WebP .webp image/webp
TIFF .tiff, .tif image/tiff
BMP .bmp image/bmp
SVG .svg image/svg+xml
 

What's banned MIME type?

Some MIME types are considered dangerous and may be blocked by browsers or security software. These are typically types that could execute code, such as:
  • application/x-msdownload – Executable files
  • application/x-sh – Shell scripts
  • application/x-javascript – JavaScript (though this is sometimes allowed)
  • text/html – Can be dangerous if served from untrusted sources
image/jpeg is not banned. It is a safe, standard MIME type for images.
 

How to know MIME type?

You can check the MIME type of a file in several ways:
  1. Using browser developer tools 📌 Open DevTools (F12), go to the Network tab, reload the page, and click on an image. Look for "Content-Type" in the response headers.
  2. Using command line 📌 On Linux/Mac, use the file command: file --mime-type image.jpg
  3. Using online tools 📌 Many websites can analyze a file and report its MIME type.
  4. Using programming 📌 In Python, you can use the mimetypes module or libraries like python-magic.
 

How do I name JPG files?

JPG files can be named with either .jpg or .jpeg extensions. Both are valid and work the same way.

Best practices for naming JPG files:
  • Use lowercase extensions (.jpg or .jpeg) for consistency
  • Avoid spaces – use hyphens or underscores instead
  • Use descriptive names that reflect the content
  • Keep filenames reasonably short but meaningful
  • Example: sunset-beach.jpg instead of IMG_12345.jpg
The file extension does not affect the MIME type. A properly configured server will send image/jpeg regardless of whether the file is named .jpg or .jpeg.
 

How to set the correct MIME type for JPG on servers

On Apache

In your .htaccess file or Apache configuration:
AddType image/jpeg .jpg .jpeg .jpe

On Nginx

In your mime.types file or nginx.conf:
types {
    image/jpeg    jpg jpeg jpe;
}

On IIS

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 use the correct MIME type in HTML

In HTML, you don't set the MIME type directly 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>
For the JPG fallback, you do not need to specify a type. But if you were to specify, it would be type="image/jpeg".
 

Common MIME type mistakes to avoid

  • Using image/jpg instead of image/jpeg
  • Using uppercase letters (image/JPEG)
  • Forgetting to configure the server for .jpe extensions
  • Sending application/octet-stream for images (forces download)
  • Not checking what MIME type your server actually sends

Remember: The correct MIME type for JPG files is always image/jpeg. Never use image/jpg. Configure your server correctly, and your images will display properly for all users.

 

The bottom line: JPG MIME type

The correct MIME type for JPG files is image/jpeg. This applies to all JPEG files regardless of whether they use .jpg, .jpeg, or .jpe extensions.

Using the correct MIME type ensures:
  • Images display correctly in all browsers
  • No unexpected downloads
  • Proper API validation
  • Better security
  • Standards compliance
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 detailed information, read our complete guides on content type JPG and JPG content type.
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.
Application hors ligne !