JSON Lines and NDJSON Guide
Learn how JSON Lines and NDJSON differ from a single JSON array, and how to validate logs, streams and exports safely. This Formalint reference is written for working developers, DBAs and support engineers who need a repeatable debugging path instead of a one-line snippet with no context.
Use the notes below as a practical review order: understand the input, capture evidence, make one small change and verify the result before moving to the next assumption.
When to use this page
Debug newline-delimited JSON exports without wrapping everything by instinct. It is most useful when a small validation or debugging mistake can create noisy tickets, misleading logs or hard-to-review production changes.
Practical workflow
| Step | What to confirm |
|---|---|
| Validate each line | Every non-empty line should be an independent JSON object. |
| Keep order meaningful | Streaming exports often depend on sequence and timestamps. |
| Convert only when needed | Wrap lines into an array for tools that require one JSON document. |
NDJSON sample
{"level":"info","message":"job started"}
{"level":"warn","message":"retry scheduled"}
{"level":"info","message":"job finished"}Review checklist
- Reject blank lines or decide how the importer handles them.
- Do not add commas between NDJSON records.
- Check that each line has the same expected fields when importing.
- Keep large log samples small before pasting into web tools.
- Record whether the file extension is .jsonl or .ndjson.
Common mistake
A valid NDJSON file is not valid as one normal JSON document. That is expected, not broken.
Formalint is strongest when the page helps the developer decide what the tool cannot prove. Treat every formatter, regex and command as one layer of evidence, not the whole truth.
Frequently asked questions
Can I format NDJSON with a JSON formatter?
Only one line at a time unless the tool specifically supports NDJSON.
Why use NDJSON?
It is convenient for logs, streams and large exports because each line can be processed independently.
Related Formalint references
Continue with JSON Diff, Regex Log Parser, CSV to JSON.