Search code examples
jsonmime-typescontent-type

Which JSON content type do I use?


There are many "standards" for the JSON content type:

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

Which one do I use, and where? I assume security and browser support issues are a factor.

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


Solution

  • 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: