content

Content-Type

Declares the media type of the body in both requests and responses, and often carries additional parameters like charset or boundary. Governs how the recipient parses or renders the payload.

Content-Type: <type>/<subtype>[; parameter=value ...]  (e.g. application/json; charset=utf-8, multipart/form-data; boundary=...)

Common directives / values

Directive Purpose
application/json JSON payloads; charset is UTF-8 by definition (RFC 8259).
text/html; charset=utf-8 HTML documents — always declare a charset.
application/x-www-form-urlencoded Classic HTML form submissions.
multipart/form-data; boundary=<b> File uploads — the boundary parameter delimits parts.
application/octet-stream Arbitrary binary — often triggers a download.
text/event-stream Server-Sent Events (SSE) streaming responses.

Examples

Content-Type: application/json

JSON API request or response body.

Content-Type: text/html; charset=utf-8

Standard HTML page — the charset param prevents mojibake.

Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxk

Browser file upload; boundary separates parts inside the body.

Content-Type: application/pdf

PDF response — combine with Content-Disposition to force download or inline view.

Gotcha

Missing or wrong Content-Type combined with X-Content-Type-Options: nosniff will cause the browser to refuse the resource (blocked stylesheet/script). Never add charset to application/json — the spec forbids it (though most parsers ignore it).

Related headers

← All HTTP headers · HTTP status codes · Fix CORS errors