.ndjson MIME type
Newline-delimited JSONtext & code
application/x-ndjsonOne JSON value per line — the format for streaming records, logs and bulk imports. Also called JSON Lines.
| MIME type | application/x-ndjson |
|---|---|
| Extensions | .ndjson, .jsonl |
| Also seen as | application/jsonl |
| Content-Type | application/x-ndjson |
| Compress in transit? | Yes — enable gzip or Brotli |
Good to know
- No type is registered.
application/x-ndjsonis the de facto choice, and it's what Elasticsearch's_bulkAPI asks for.application/jsonlalso shows up for.jsonlfiles. - Streaming APIs send one record per line as soon as it's ready. On the client, read the body as a stream, split on newlines and
JSON.parseeach complete line. - Not the same as
application/json-seq(RFC 7464), which puts an ASCII record-separator byte (0x1E) before each record.
Useful here: JSON validator
Serve .ndjson files with the right type
The response header to send:
Content-Type: application/x-ndjson
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/x-ndjson ndjson jsonl;
Apache (.htaccess or server config)
AddType application/x-ndjson .ndjson .jsonl
Express
res.set("Content-Type", "application/x-ndjson");Python
import mimetypes
mimetypes.add_type("application/x-ndjson", ".ndjson")
mimetypes.add_type("application/x-ndjson", ".jsonl")HTML file input
<input type="file" accept=".ndjson,.jsonl,application/x-ndjson">
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.ndjson | grep -i '^content-type:' file --mime-type file.ndjson
Frequently asked questions
What is the MIME type for .ndjson files?
application/x-ndjson. You may also see application/jsonl, but application/x-ndjson is the one to send. The same type covers .jsonl.
What Content-Type header should a .ndjson file be served with?
Content-Type: application/x-ndjson. 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