Guide
Working with JSON Lines: validating, flattening and converting
JSON Lines, also called NDJSON, is the format of application logs, analytics exports, message queues and AI training data: one JSON value per line, so a file can be appended to and processed one record at a time. It is ideal for machines and awkward for people, because spreadsheets cannot open it and a single broken line stops most parsers. This converter checks every line and turns the file into CSV, a JSON array or clean JSON Lines.
The format in one paragraph
The rules from jsonlines.org are short: the file is UTF-8, each line holds one complete JSON value, and lines are separated by a newline. Pretty-printed JSON that spans several lines is therefore not valid JSON Lines. Most files hold one object per line, but any JSON value is allowed. Blank lines are not part of the specification; the converter simply ignores them.
Line-by-line validation
Every non-empty line is parsed on its own. A line that fails is listed with its line number and the parser’s message, so you can find a truncated record or a stray comma at once. With “Skip invalid lines” on, the bad lines are left out and the rest is converted; turn it off when a missing record would make the output wrong and you would rather stop.
Flattening for CSV
CSV has no nesting, so objects inside a record are flattened into dotted column names: {"user":{"name":"Ada"}} becomes a column called user.name. Arrays stay as JSON text in one cell, because spreading them into extra columns or rows would change what a row means. Columns are collected from every record in the order they first appear, not just from the first line, so a field that only shows up halfway through the file still gets its column.
A worked example
The Sample has five lines of event data, and line 4 is cut off in the middle of a record. In JSONL to CSV mode the tool reports “Line 4” as invalid, skips it and writes four data rows under the header id,event,user.name,user.plan,tags,ts,amount. The third row is 3,purchase,Ada,pro,,2026-10-30T09:12:40Z,49.5: the tags cell is empty because that record has no tags, and amount comes last because it first appears in that record.
The other conversions
JSONL to JSON array wraps the valid records in square brackets for tools that expect a single document. JSON array to JSONL does the reverse, writing each element on its own line. CSV to JSONL reads a spreadsheet export with a header row and produces one object per row with string values, a common first step when building a fine-tuning or evaluation file. Clean JSONL rewrites every record compactly, which also repairs files where someone pretty-printed the records.
What does not survive
CSV values are text, so numbers and booleans lose their type on the way back from CSV to JSON Lines. Arrays in CSV cells remain JSON strings. Very large files work, but the whole file is held in the browser tab, so multi-gigabyte logs are better split first.
Files for AI fine-tuning
Chat fine-tuning formats expect one object per line with a messages array. Building them from a spreadsheet works in two steps: export the examples to CSV, convert them here to JSON Lines, then reshape the fields in a script or with the Prompt Template Filler. Running the finished file back through validation confirms that every line parses before you upload it.
Related tools
- CSV to JSON converts spreadsheets to a regular JSON document.
- JSON Formatter pretty-prints and validates a single record.
- Parquet Viewer opens the columnar files many pipelines produce from JSON Lines.
- JSON to SQL loads records into a database table.
Checked against the current version of the JSON Lines Converter on .

