Categories
json

What is the correct JSON content type?

11223

There are many “standards” for the JSON content type:

application/json
application/x-javascript
text/javascript
text/x-javascript
text/x-json

Which one is best? I assume security and browser support issues are a factor.

Related: What MIME type if JSON is being returned by a REST API?

0

11267

For JSON text:

application/json

The MIME media type for JSON text is application/json. The default encoding is UTF-8. (Source: RFC 4627)

For JSONP (runnable JavaScript) with callback:

application/javascript

Here are some blog posts that were mentioned in the relevant comments:

9

1757

IANA has registered the official MIME Type for JSON as application/json.

When asked about why not text/json, Crockford seems to have said JSON is not really JavaScript nor text and also IANA was more likely to hand out application/* than text/*.

More resources:

5

993

For JSON:

Content-Type: application/json

For JSON-P:

Content-Type: application/javascript

1