What is NDJSON and when to use it
Why newline-delimited JSON exists, how it differs from a plain JSON array, and where streaming records beats one big document.
One record per line, by design
NDJSON stands for newline-delimited JSON, and the whole format is a single rule: put one complete, independent JSON value on each line. There is no wrapping array, no commas between records and no trailing bracket. That sounds trivial, but it changes what software can do with the file. A reader can consume one line, act on it, and forget it before the next line arrives, which is exactly what you want for logs, exports and event streams that never really end.
How it differs from a JSON array
A regular JSON array is one document: to be valid it must start with an opening bracket and finish with a closing bracket, so a parser generally has to load the entire thing before it can trust any of it. NDJSON has no such ceremony. Each line stands alone, so a half-written file is still useful up to its last complete line, and you can append new records simply by writing another line. The trade-off is that most viewers and APIs still expect a proper array, which is why converting between the two is such a common chore.
Where NDJSON shines
Streaming is the classic fit. Log pipelines, analytics exports, database dumps and message queues all emit records over time rather than as one finished blob. Writing each event as its own line means a crash loses only the record in flight, and downstream tools can start processing immediately instead of waiting for a final bracket. Many big-data tools, including BigQuery and Elasticsearch bulk loads, accept line-delimited JSON directly for exactly these reasons.
Converting without losing data
Turning NDJSON into an array is mechanical: gather every non-empty line, parse each as JSON, and collect the results into a list. This tool does exactly that and pretty-prints the outcome, while skipping blank lines so stray newlines do not create phantom entries. Going the other way, it writes each array element back to a single compact line. The one thing to watch is that a JSON array can hold trailing structure NDJSON cannot express inline, so always convert a top-level array rather than a nested one.