What is MIME type "image/webp"?

A MIME type is a string that tells browsers and other tools how to handle a particular kind of file.

The image/webp MIME type marks images in the WEBP format. It is used primarily for online graphics.

The format offers high compression. File sizes drop while detail remains clear.

Modern browsers support this type widely. Many websites choose it for speed and efficiency.
Additional information is available at Google WebP.

Associated file extensions

Usage Examples

HTTP Header

When serving content with this MIME type, set the Content-Type header:


    Content-Type: image/webp    
  

HTML

In HTML, you can specify the MIME type in various elements:


    <a href="file.dat" type="image/webp">Download file</a>    
  

Server-side (Node.js)

Setting the Content-Type header in Node.js:


    const http = require('http');    
    
    http.createServer((req, res) => {    
      res.setHeader('Content-Type', 'image/webp');    
      res.end('Content here');    
    }).listen(3000);    
  

Associated file extensions

FAQs

Why should I use image/webp instead of JPEG or PNG?

WebP offers superior compression, often making files 25-34% smaller than comparable JPEGs without significant quality loss. It combines the best features of other formats, supporting both lossy and lossless compression, as well as transparency like image/png.

Which browsers support the image/webp MIME type?

All modern browsers, including Google Chrome, Firefox, Microsoft Edge, and Apple Safari (version 14+), fully support WebP. For legacy browsers like Internet Explorer, developers should provide a fallback image using the HTML <picture> element.

How do I configure Apache to serve WebP files with the correct MIME type?

Add the directive AddType image/webp .webp to your .htaccess file or main configuration. This ensures the server sends the Content-Type: image/webp header, allowing browsers to render the image rather than downloading it.

Can WebP replace GIFs for animation?

Yes, WebP supports animation and typically produces significantly smaller file sizes than image/gif. Unlike GIF, which is limited to 256 colors, WebP animations support 24-bit color and 8-bit alpha transparency.

How do I implement WebP with a fallback for older browsers?

Use the <picture> tag in your HTML. Place a <source srcset="image.webp" type="image/webp"> before the standard <img> tag containing a JPEG or PNG; the browser will automatically select the first format it supports.

What happens if my server sends the wrong MIME type for a .webp file?

If a server sends a generic type like application/octet-stream or text/plain, the browser might download the file instead of displaying it. Always ensure your web server configures the extension .webp to map to image/webp.

Is image/webp a secure format?

Generally, yes, but like all image parsing libraries, decoders can have vulnerabilities. Ensure your browser and server software are up to date. Security tools treat it similarly to image/jpeg regarding potential steganography or malformed header exploits.

General FAQ

What is a MIME type?

A MIME (Multipurpose Internet Mail Extensions) type is a standard that indicates the nature and format of a document, file, or assortment of bytes. MIME types are defined and standardized in IETF's RFC 6838.

MIME types are important because they help browsers and servers understand how to process a file. When a browser receives a file from a server, it uses the MIME type to determine how to display or handle the content, whether it's an image to display, a PDF to open in a viewer, or a video to play.

MIME types consist of a type and a subtype, separated by a slash (e.g., text/html, image/jpeg, application/pdf). Some MIME types also include optional parameters.

How do I find the MIME type for a file?

You can check the file extension or use a file identification tool such as file --mime-type on the command line. Many programming languages also provide libraries to detect MIME types.

Why are multiple MIME types listed for one extension?

Different applications and historical conventions may use alternative MIME identifiers for the same kind of file. Showing them all helps ensure compatibility across systems.