What is the correct Content Type for JSON?

The official MIME type for JSON (JavaScript Object Notation) is application/json, and the default encoding is UTF-8. For JSONP (padded JSON), the correct content type is application/javascript. For JSON-LD (JSON linked data), the correct content type is application/ld+json. There are some legacy content types for JSON that should be avoided (text/json, text/x-json, text/javascript, etc.).
What is the correct Content Type for JSON? Send
POST /echo/post/json HTTP/1.1
Host: reqbin.com
Accept: application/json
Content-Type: application/json
Content-Length: 81

{
  "Id": 78912,
  "Customer": "Jason Sweet",
  "Quantity": 1,
  "Price": 18.00
}
Updated: Viewed: 8466 times

Why is it important to specify the correct content type for JSON?

Every resource transmitted over HTTP has a media type, also known as a MIME type, which is used to describe the resource type in the body of an HTTP message and allows browsers and servers to interpret them correctly. For example, if the server can accept JSON and XML content types on the same endpoint, then setting Content-Type to application/json will tell the server to interpret the data in the body as JSON, and setting Content-Type to application/xml will tell the server to interpret the data as XML.

Content-Type: application/json

Example of sending JSON with correct Content-Type header

Example of posting JSON data to the ReqBin echo URL.

JSON Request Example
POST /echo/post/json HTTP/1.1
Host: reqbin.com
Content-Type: application/json
Content-Length: 81

{
  "Id": 78912,
  "Customer": "Jason Sweet",
  "Quantity": 1,
  "Price": 18.00
}

Example of getting JSON with correct Content-Type header

An example of loading JSON data from the ReqBin echo URL.

JSON Response Example
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 19

{"success":"true"}

See also JSON Request Example, JSON Response Example.

Generate Code Snippets for JSON Content Type Example

Convert your JSON Content Type request to the PHP, JavaScript/AJAX, Curl/Bash, Python, Java, C#/.NET code snippets using the ReqBin code generator.