Content-Type Header Explained
What the HTTP Content-Type header does and when it's used.
Published October 13, 2026
Content-Type tells the receiver the media type (MIME type) and optional charset of the message body, such as application/json or text/html; charset=utf-8.
How it works
Both requests and responses use it. Servers use it to decide how to parse a body, and browsers use it to decide how to render a response.
The Content-Type header is part of the HTTP message and is case-insensitive in name.
In a real exchange
curl -i https://example.com/
Content-Type: application/json; charset=utf-8
Practical examples
The header
Content-Type: application/json; charset=utf-8Set or use it in code
fetch('/api', { method:'POST', headers:{'Content-Type':'application/json'}, body: JSON.stringify(data) })Inspect it
curl -sI https://example.com | grep -i 'content-type'Common mistakes
- Sending JSON without the header so the server cannot parse it
- Wrong charset causing garbled text
- Letting browsers sniff types instead of setting X-Content-Type-Options: nosniff
Key takeaways
- Content-Type: Content-Type tells the receiver the media type (MIME type) and optional charset of the message body, such as application/json or text/html; charset=utf-8.
- Check it in browser DevTools → Network.
- Test with curl -I before deploying.
FAQ
What types are common?
text/html, application/json, application/x-www-form-urlencoded, multipart/form-data, image/png.
Is Content-Type case sensitive?
Header names are case-insensitive; values may not be.