Skip to content
JSON

Streaming (NDJSON)

Newline-delimited JSON for streaming.

#ndjson#streaming#jsonl

Code

json
{"name":"Alice","id":1}
{"name":"Bob","id":2}
{"name":"Charlie","id":3}

// Each line is a self-contained JSON object.
// NDJSON lets parsers emit records incrementally
// without loading the whole file into memory.

// Read in Node.js:
// const rl = readline.createInterface({ input: fs.createReadStream("data.ndjson") });
// rl.on("line", line => console.log(JSON.parse(line)));