Skip to content
Toolew.com

NDJSON Converter

Convert NDJSON or JSON Lines to a JSON array and back, validating every line and pinpointing bad records by line and column.

Runs in your browser. Your data is not uploaded.
Loading tool…

Tool guide

What this tool does

NDJSON Converter turns newline-delimited JSON, also called JSON Lines or JSONL, into a standard JSON array, and turns a JSON array into one compact record per line. Every line is validated: invalid records stop the conversion with their exact line and column, or can be skipped and listed. Blank lines are ignored and direction can be detected automatically.

Newline-delimited JSON stores one complete JSON value per line. It is the format behind structured logs, BigQuery and Elasticsearch bulk imports, OpenAI fine-tuning files, data-pipeline exports and streaming APIs, because a program can process one record at a time without loading the whole file. Most other tools, though, expect a single JSON array, and a single malformed line can make a whole import fail with a vague error.

This converter goes both ways. NDJSON to JSON parses each line independently with the browser’s native parser, ignores blank lines and collects the records into an array. If a line is invalid, a second diagnostic parse finds the exact column, and you see the line number, the reason and the surrounding lines, or you can choose to skip bad lines and get a list of them. JSON array to NDJSON writes each item as compact JSON on its own line, and can unwrap responses such as { "data": [ … ] }. Large files are handled line by line in your browser.

How to use NDJSON Converter

  1. Paste NDJSON or a JSON array into the input box, open a .ndjson, .jsonl or .log file, or click Sample.
  2. Leave Conversion on Detect automatically, or choose the direction explicitly.
  3. Pick the JSON array indentation when converting to an array.
  4. Decide whether to Skip invalid lines instead of stopping at the first error.
  5. For NDJSON output, choose whether to unwrap a single object holding the array and whether to use CRLF.
  6. Review the Records and Invalid lines figures, then copy or download the result.

Tips for better results

  • Skipping invalid lines is useful for log files where a process crashed mid-write and left a truncated last line.
  • NDJSON lines must not contain raw line breaks; the converter writes each record compactly, escaping line breaks inside strings as \n.
  • Use Use output as input to check a round trip: array to NDJSON and back should give the same records.
  • For OpenAI fine-tuning or batch files, each line must be an object; check the Records count matches what you expect.

Common use cases

  • Turning application logs into an array for analysis in a spreadsheet or JSON viewer.
  • Preparing JSONL training or batch files from a JSON array.
  • Converting BigQuery, MongoDB or Elasticsearch exports between formats.
  • Finding the single malformed record that makes a bulk import fail.

Common mistakes to avoid

  • Pretty-printing records across several lines in an NDJSON file; each record must sit on exactly one line.
  • Adding commas at the end of lines or wrapping the file in [ ]; NDJSON has neither.
  • Saving the file with a byte-order mark or a non-UTF-8 encoding, which some importers reject.

Frequently asked questions

Are NDJSON, JSON Lines and JSONL the same thing?

For practical purposes, yes. All three describe UTF-8 text with one valid JSON value per line separated by \n. The usual file extensions are .ndjson and .jsonl.

How does automatic detection work?

If the input starts with [ or is an object spread over several lines, it is treated as JSON and converted to NDJSON. Otherwise each line is treated as a record and the result is a JSON array.

What happens to blank lines?

They are ignored when converting NDJSON to JSON, which matches how most NDJSON readers behave. They are never written when producing NDJSON.

Can it handle large log files?

Yes. Each line is parsed separately with the fast native parser, so files of many megabytes convert quickly, and the slower diagnostic parser runs only on lines that fail.

Feedback & suggestions

Help us improve NDJSON Converter. We read every message.

Rating (optional)
Necessary
Required for security, language and theme preferences. Always on.