NDJSON / JSON Lines Formatter & Validator

Validate and pretty-print newline-delimited JSON, or convert to/from a regular JSON array

Output will appear here…
NDJSON (newline-delimited JSON, also called JSON Lines) encodes one independent JSON value per line instead of one big array β€” the format streaming APIs, log files, and LLM token-by-token output commonly use, since a consumer can process each line as it arrives without waiting for a closing ]. Blank lines are skipped.

About this tool

The ToolNinja NDJSON / JSON Lines Formatter validates and pretty-prints newline-delimited JSON β€” one independent JSON value per line, rather than one big array β€” the format behind streaming API responses, log files, and increasingly, token-by-token LLM output. Each line is parsed and validated independently, so a single malformed line is reported with its exact line number rather than failing the whole input the way a single JSON.parse() over the full text would. A Convert mode turns valid NDJSON into a regular JSON array (and back) for the cases where you need the data in one format or the other β€” exporting NDJSON logs into a JSON array for a script that expects one, or splitting a JSON array into NDJSON for a streaming pipeline. Everything runs 100% in your browser β€” your log data or API response never leaves your machine.

When to use it

  • β†’Validating a log file or API response that uses NDJSON/JSON Lines format, with exact line numbers for any malformed entries
  • β†’Converting NDJSON log output into a regular JSON array for a script or tool that doesn't support the line-delimited format
  • β†’Converting a JSON array into NDJSON for a streaming pipeline or bulk-import API that expects one record per line
  • β†’Pretty-printing minified NDJSON log lines to read them more easily during debugging

Tips

  • β—†Blank lines are silently skipped β€” they're a common artifact of how NDJSON files get generated and aren't treated as errors.
  • β—†Converting to a JSON array requires every line to be valid first β€” fix the lines listed as errors before the array conversion will produce output.
  • β—†NDJSON and JSON Lines (.jsonl) are the same format under different names β€” both mean exactly one JSON value per line, no trailing comma, no wrapping array.

Frequently asked questions

What's actually different between NDJSON and a regular JSON array?

A JSON array must be fully received and parsed as one unit β€” you can't know the array is 'done' until you see the closing ]. NDJSON has no wrapping structure at all; each line is independently complete and parseable the moment it arrives, which is exactly why streaming APIs and log pipelines prefer it β€” a consumer can process line 1 while line 50,000 is still being generated.

Why do LLM streaming APIs often use a line-delimited format?

Token-by-token generation produces output incrementally, and a consumer needs to process each chunk as it arrives rather than waiting for the full response β€” the same requirement NDJSON was designed for. Many LLM streaming endpoints use NDJSON directly, or a closely related line-delimited event format (like text/event-stream), for this reason.

Can NDJSON have trailing commas or wrap everything in brackets?

No β€” each line must be a complete, standalone JSON value with no trailing comma and no enclosing array brackets. A file that starts with [ and separates entries with commas is a regular (possibly pretty-printed) JSON array, not NDJSON, even if it has one value per line.

Related tools

πŸ₯· ToolNinja