Overview
Introduction
Logs and streaming APIs often produce JSON Lines, one JSON object per line, but spreadsheets and most reporting tools want CSV. This tool converts JSONL back into a proper CSV file.
It builds the CSV header from every key it sees across the whole file, not just the first line, so records with extra or missing fields still line up correctly.
What Is JSON Lines (JSONL) to CSV Converter?
A JSONL-to-CSV converter that reads one JSON object per non-empty line and produces a CSV file whose header is the union of every key seen anywhere in the input, in first-seen order.
It's the reverse of CSV to JSONL Converter, reconstructing tabular rows from the same newline-delimited JSON object shape.
How JSON Lines (JSONL) to CSV Converter Works
Each non-empty line is parsed independently with `JSON.parse`; if a line fails to parse, or parses to something other than a plain object (an array, string, or number), conversion stops with an error naming that line.
Once every line is parsed, the union of every object's keys (tracked in the order first seen) becomes the CSV header, and each record is mapped into a row using that header, with a missing key producing an empty cell and a nested object/array re-stringified into its cell.
When To Use JSON Lines (JSONL) to CSV Converter
Use it when you've pulled JSON Lines out of a log file, streaming export, or bulk API response and need it in a spreadsheet or reporting tool that expects CSV.
It's also useful for quickly checking how consistent a JSONL file's schema is, since any key that's missing from some records shows up as an empty cell.
Often used alongside CSV to JSON Lines (JSONL) Converter, SQL INSERT to CSV Converter and HTML Table to CSV Converter.
Features
Advantages
- Builds the header from every line's keys, not just the first, so schema drift across records doesn't misalign columns.
- Gives a clear, line-numbered error the moment it hits invalid JSON or a non-object line, instead of silently producing bad output.
- Runs entirely client-side, so the data never leaves your browser.
Limitations
- Nested objects and arrays aren't flattened into separate columns; they're kept as their raw JSON text inside a single cell.
- Every line must be a JSON object; a file mixing objects with bare arrays or primitive values on some lines will fail with an error rather than skip those lines.
Examples
Best Practices & Notes
Best Practices
- If you get a line-numbered error, open that exact line in the source file first; it's almost always a stray trailing comma or an unquoted key from hand-editing.
- Expect a wide, sparse CSV if your JSONL records vary a lot in shape; consider splitting by record type first if that's not what you want.
- Use CSV to JSONL Converter afterward to confirm a round trip reproduces equivalent records.
Developer Notes
Key order for the header is tracked as an array populated on first sight of each key, rather than collected into a Set and later sorted, since preserving first-seen order keeps the resulting CSV's column order intuitive and matching the source data's natural field order instead of an arbitrary alphabetical one.
JSON Lines (JSONL) to CSV Converter Use Cases
- Converting a log export or streaming API's JSONL output into a spreadsheet for reporting
- Auditing schema consistency across a JSONL file by seeing which columns end up sparsely populated
- Migrating newline-delimited JSON data into any tool that only accepts CSV
Common Mistakes
- Feeding it a single, regular JSON array file instead of true JSONL; each line must be its own complete JSON object.
- Expecting nested objects/arrays to expand into their own columns; they're preserved as raw JSON text in one cell instead.
Tips
- If the header looks unexpectedly wide, check for a single malformed or unusually-shaped record contributing stray one-off keys.
- Pair with CSV to JSONL Converter to confirm the round trip preserves the fields and values you expect.