MIME Type Lookup & Content-Type Directory
Identify the official IANA media type for any file extension. Copy exact Content-Type headers, Nginx server directives, and Express.js response snippets.
.json
applicationJavaScript Object Notation (REST APIs, configs)
application/json
Recommended (Compressible)
Protected by nosniff
Server Response Header Snippets
Content-Type: application/json X-Content-Type-Options: nosniff Cache-Control: public, max-age=31536000, immutable
res.setHeader('Content-Type', 'application/json');
res.setHeader('X-Content-Type-Options', 'nosniff');types {
application/json json;
}Web Security, MIME Sniffing & Content-Type Guide
01.What is MIME Sniffing & Why It Is Dangerous
When a web server returns a file without an explicit Content-Type or with a generic type, browsers historically attempted to "sniff" (guess) the format by inspecting the initial bytes of the body.
This creates severe Cross-Site Scripting (XSS) vulnerabilities. For example, if an attacker uploads a malicious image containing disguised JavaScript code and the browser sniffs it as text/html, the script executes within the victim's origin session. Always send:
02.Modern Web Media: AVIF, WebP & WOFF2
Modern web assets achieve dramatically smaller payload sizes, but only if web servers declare their standard MIME types:
- image/avif: The AV1 image container achieves 20% to 50% better compression than WebP and JPEG. Requires explicit web server configuration on older Linux distributions.
- image/webp: Universal across all modern browsers. Delivers both lossy and lossless transparent compression.
- font/woff2: Pre-compressed using the Brotli algorithm. Web servers should never attempt to gzip or re-compress
.woff2files, as this wastes CPU cycles without size reductions.
03.The application/octet-stream Fallback
The MIME type application/octet-stream indicates arbitrary binary data.
Browsers handle octet-stream responses by prompting the user to download the file rather than displaying it inline. When forcing a download, combine it with the Content-Disposition header:
04.Specifying Character Encodings (charset=utf-8)
For text and document resources (text/html, text/plain, text/css, and text/csv), always specify the character set:
Omitting the charset parameter can cause browsers to misinterpret unicode characters, resulting in mojibake (scrambled glyphs) or security issues.