What is NDJSON?
One JSON value per line: the format behind log pipelines and bulk APIs, and why it streams when a JSON array cannot.
4 minute read · Updated August 2026One complete JSON value per line
NDJSON — also seen as JSON Lines or .jsonl — puts one self-contained JSON value on each line, separated by newlines. There is no enclosing array and no commas between records. Each line parses on its own with an ordinary JSON parser.
That constraint is the entire feature. Because every line is independent, a reader can process a file of any size with constant memory, and a writer can append a record by appending a line.
{"id":"ord_101","status":"paid","total":129.5}
{"id":"ord_102","status":"failed","total":42}Why a JSON array cannot do this
A JSON array is a single value: it is not complete until its closing bracket arrives. A conventional parser must therefore hold the whole document before it can hand you anything, and a file truncated by a crashed process is invalid in its entirety — you lose every record, not just the last one.
With NDJSON a truncated file costs you one partial line. This is why it dominates log shipping, analytics exports, bulk-import APIs, and streaming responses, and why several databases accept it as their bulk ingest format.
Conversion is not symmetric
NDJSON to JSON is well defined: collect the lines into an array. JSON to NDJSON is only well defined when the input is an array — then each element becomes a line. A JSON object at the root has no natural line-per-record reading, so the whole document becomes a single line, which is valid NDJSON but rarely what was wanted.
Two operational details matter more than the syntax: lines must not contain unescaped newlines, which is automatic since JSON escapes them inside strings, and the file should be UTF-8 without a byte-order mark, since a BOM belongs to the file rather than to the first record.