What is the Content Type for JSON?

To help services understand the type of data they are receiving, they may want to know what type of content they're receiving, also known as MIME type. We can't always tell from the content itself what type it is, which is why we give this content type hint.

For a variety of reasons, this is not always obvious for JSON content as it can be used in a number of ways, and there are a few variations on it, like JSONP.

JSON

For plain JSON text, the content type is:

application/json

You might be confused by a number of different MIME types floating around the Internet, but to clear things up, you can find that this is the official content type as stated in RFC 4627.

Get free courses, guided projects, and more

No spam ever. Unsubscribe anytime. Read our Privacy Policy.

Here are a few other MIME types that have also been used for JSON, but these are not the official content types, so beware:

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

JSONP

If you're using JSONP (aka JSON with Padding), you'd use the content type:

application/javascript

This is because JSONP is not actually JSON, but a JavaScript file that contains JSON data, which is returned to the caller via a callback method. While the name might be deceiving, remember that JSONP merely uses JS to pass JSON data.

For reference, you can find the full list of MIME types in the IANA Media Types page.

Last Updated: June 7th, 2023
Was this helpful?
Project

React State Management with Redux and Redux-Toolkit

# javascript# React

Coordinating state and keeping components in sync can be tricky. If components rely on the same data but do not communicate with each other when...

David Landup
Uchechukwu Azubuko
Details

© 2013-2024 Stack Abuse. All rights reserved.

AboutDisclosurePrivacyTerms