application/x-ndjson
Application

Overview

application/x-ndjson is the media type for Newline-Delimited JSON — one complete JSON object per line, separated by newlines (\n). It is widely used for streaming large numbers of records and for log and data pipelines (the same idea as JSON Lines/JSONL).

Details

Unlike one giant JSON array, NDJSON makes each line an independent document, so you can parse and process line by line without loading the whole thing into memory. This lets a server stream results as it produces them (chunked transfer) and a client process each record as it arrives. Elasticsearch's _bulk API, log collectors, and large exports are typical uses.

Each line must itself be valid JSON with no literal newline inside it (newlines within strings are escaped as `\n`). Whether the final line has a trailing newline varies by parser, so handle it leniently. For real-time server-to-client events, text/event-stream (SSE) via the browser's EventSource is a better fit, while NDJSON excels at general-purpose data streaming.

Syntax

e.g. Content-Type: application/x-ndjson

File extensions

.ndjson.jsonl

Notes

Related types

Related headers