devkult_
tools29converters34
home/mime/.json

.json MIME type

JSONtext & code

application/json

JSON data. UTF-8 by definition, so the type takes no charset parameter.

MIME typeapplication/json
Extensions.json
Content-Typeapplication/json
Compress in transit?Yes — enable gzip or Brotli

Good to know

  • text/json and text/x-json are non-standard; some old clients send them, but servers should respond with application/json.
  • Express needs app.use(express.json()) to parse request bodies, and only parses requests whose Content-Type matches.
  • Formats built on JSON use the +json suffix: application/ld+json, application/problem+json, application/manifest+json.

Useful here: JSON formatter · JSON to TypeScript · Unexpected token in JSON

Serve .json files with the right type

The response header to send:

Content-Type: application/json

Most servers pick the type from the file extension. If yours sends the wrong one, map it explicitly:

nginx (inside the types block in mime.types)
application/json json;
Apache (.htaccess or server config)
AddType application/json .json
Express
res.set("Content-Type", "application/json");
Python
import mimetypes

mimetypes.add_type("application/json", ".json")
HTML file input
<input type="file" accept=".json,application/json">

Check it

See what a server sends for a file, and what type a local file really is by its contents:

curl -sI https://example.com/file.json | grep -i '^content-type:'
file --mime-type file.json

Frequently asked questions

What is the MIME type for .json files?

application/json.

What Content-Type header should a .json file be served with?

Content-Type: application/json. It compresses well, so let the server apply gzip or Brotli.

Related types

Headers that go with it: Content-Type · Content-Disposition · X-Content-Type-Options