DELAPARRA
Index
Color
NL
Category: HTTP headers

Content-Type

Explained by Updated

What is Content-Type?

Content-Type: The media type of the request body. Required when sending a body. Content-Type tells the receiver what kind of data is in the body and how it is encoded. text/html; charset=utf-8 for web pages, application/json for API data, multipart/form-data for file uploads. The server uses it on requests to decide how to read the body. Send JSON without Content-Type: application/json and many frameworks will not parse it, so your code sees empty input.

Definition source Coders Lingo, CC BY 4.0

Frequently asked questions about Content-Type

What should you keep in mind with Content-Type?

On responses, browsers rely on it to decide what to do with the data. Always set the correct type and character set. Add X-Content-Type-Options: nosniff so browsers do not guess, because guessing can turn an uploaded text file into executable script. Returning JSON errors with an HTML content type, or the other way round, is a common source of confusing client bugs.

What does an example of Content-Type look like?

Content-Type: application/json; charset=utf-8

At a glance

CategoryHTTP headers
Explained by
Updated

More HTTP headers terms

All terms starting with C

Skills

Download all skills (zip)

Manuals

Related services

Need any help?

Stuck on one of these in your own project? Tell me what you are working on and I will tell you how I would approach it.