DevKits

Content · Request & Response

Content-Type

Declares the media type of the body.

What is Content-Type?

Content-Type tells the receiver how to interpret the bytes in the message body — as JSON, HTML, an image, a video, and so on. Almost every request with a body and every response with content must set it correctly, or the client / browser will misinterpret the payload.

Typical usage

Always set on responses with a body; also required on POST / PUT / PATCH requests that carry a body.

Examples

JSON body

Content-Type: application/json

HTML page (with charset)

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

Form with file upload

Content-Type: multipart/form-data; boundary=----WebKitFormBoundary...

Common gotchas

Serving a script or stylesheet with the wrong Content-Type causes the browser to reject it silently. Always match the actual bytes — a .css file must be sent as text/css.

Also known as

Also commonly written as: content type · content-type header · content type header · application/json content type · application/json content-type · mime type header · media type header · Content-Type ヘッダ · コンテンツタイプ. These variants — including plural forms, unhyphenated spellings, and Japanese (ヘッダ) — all refer to the same Content-Type HTTP header.

Specification

RFC 9110 §8.3

Frequently asked questions

What is the Content-Type HTTP header?

Content-Type tells the receiver how to interpret the bytes in the message body — as JSON, HTML, an image, a video, and so on. Almost every request with a body and every response with content must set it correctly, or the client / browser will misinterpret the payload.

Is Content-Type a request or response header?

Content-Type can appear on both requests and responses. Always set on responses with a body; also required on POST / PUT / PATCH requests that carry a body.

What does a Content-Type header look like?

A typical Content-Type header looks like: Content-Type: application/json (JSON body).

What are common mistakes with Content-Type?

Serving a script or stylesheet with the wrong Content-Type causes the browser to reject it silently. Always match the actual bytes — a .css file must be sent as text/css.

Related headers

Work with this header