MIME Types

application/json

The standard MIME type for JavaScript Object Notation (JSON) data interchange.

What Is This?

The application/json MIME type indicates that the content being transmitted is JavaScript Object Notation (JSON) data. It is the most widely used content type for REST APIs, configuration files, and data interchange on the web. When a server sends application/json, the client knows to parse the response body as JSON rather than plain text or HTML.

Common Uses

1

Common Use

REST and GraphQL API request and response bodies

2

Common Use

Configuration files (package.json, tsconfig.json)

3

Common Use

Browser localStorage and sessionStorage data serialization

4

Common Use

WebSocket message payloads

Examples

Server Configuration

Serve files with the application/json MIME type:

# Nginx
location ~ \.json$ {
  add_header Content-Type "application/json";
}

# Apache
AddType application/json .json
HTML Usage

Use this MIME type in HTML or HTTP:

Content-Type: application/json

<!-- HTML reference -->
<link rel="preload" href="file.json" as="fetch" crossorigin>

Related Entries

More from this reference:

Frequently Asked Questions

Do I need to set application/json for every API response?

Yes. Always set Content-Type: application/json on JSON API responses. Without it, clients may not parse the response correctly and some browsers show a download prompt instead of processing the data.

What happens if I send application/json with invalid JSON?

The client will fail to parse the response and throw a JSON parse error. Always validate JSON before sending it with application/json content type.