JSON and JSONP correct MIME types

JSON (JavaScript Object Notation) and JSONP (JSON with padding) formats seems to be very similar, and therefore it might be very confusing which MIME type they should be using. Even though the formats seem to be very similar, there are some subtle differences between them.

But whenever you have any doubts, I have a straightforward solution (which works perfectly fine in most cases but sometimes might be a little bit time-consuming ;) ), namely, go and check corresponding RFC document.

JSON application/json RFC 4627
JSONP application/javascript RFC 4329


RFC 4627 (The application/json Media Type for JavaScript Object Notation (JSON)) is a specifications of JSON format. It says in section 6, that the MIME media type for JSON text is application/json.


JSONP (“JSON with padding”) is handled different way than JSON by a browser. JSONP is treated as a regular JavaScript script, and therefore it should use application/javascript, the current official MIME type for JavaScript. In many cases, however, text/javascript1 MIME type will work fine too.

Other MIME types

If you are looking for other MIME types, I would recommend checking Media Types document, which I personally find very useful.

  1. Note that text/javascript has been marked as obsolete by RFC 4329 (Scripting Media Types) document and it is recommended to use application/javascript type instead. However, due to legacy reasons, text/javascript is still widely used and it has cross-browser support (which is not always a case with application/javascript MIME type, especially with older browsers). [return]


#json #jsonp #mime

You may also be interested in:

comments powered by Disqus