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.
The primary and widely accepted MIME type for JSON content is application/json. This MIME type is specified in the official JSON specification (RFC 8259). It is the standard and recommended way to indicate that the content is JSON data.
application/json
Using application/json is considered a best practice and is widely supported across browsers and platforms. When serving JSON data over HTTP, you should set the Content-Type header in the HTTP response to application/json.
Content-Type
For example, in an HTTP response header:
Content-Type: application/json
This helps browsers and other clients correctly interpret the content.
While the other MIME types you mentioned (application/x-javascript, text/javascript, text/x-javascript, text/x-json) have been used historically or in specific contexts, they are not the standard for JSON. It’s generally recommended to stick with application/json to ensure consistency, interoperability, and compatibility with modern web standards.
application/x-javascript
text/javascript
text/x-javascript
text/x-json
In summary, for JSON content, use application/json. It’s widely supported, recognized, and aligns with the official JSON specification.