X-Content-Type-Options Header Explained
What the HTTP X-Content-Type-Options header does and when it's used.
Published October 16, 2026
X-Content-Type-Options: nosniff stops browsers from guessing (MIME-sniffing) a different content type than declared, preventing certain XSS vectors.
How it works
It is a simple, safe header for all responses.
The X-Content-Type-Options header is part of the HTTP message and is case-insensitive in name.
In a real exchange
curl -i https://example.com/
X-Content-Type-Options: nosniff
Practical examples
The header
X-Content-Type-Options: nosniffSet or use it in code
add_header X-Content-Type-Options nosniff always;Inspect it
curl -sI https://example.com | grep -i 'x-content-type-options'Common mistakes
- Serving user uploads with wrong Content-Type
- Omitting it on API and download responses
- Relying on it instead of correct types
Key takeaways
- X-Content-Type-Options: X-Content-Type-Options: nosniff stops browsers from guessing (MIME-sniffing) a different content type than declared, preventing certain XSS vectors.
- Check it in browser DevTools → Network.
- Test with curl -I before deploying.
FAQ
Any downside?
Misconfigured Content-Types will stop scripts and styles from loading.
Is X-Content-Type-Options case sensitive?
Header names are case-insensitive; values may not be.