JSONL / NDJSON Explained: From AI APIs and Logs to CSV
September 4, 2026 · RividTech
Open an AI API log, a Hugging Face dataset, or a production event stream and you will not find one big JSON array — you will find JSONL (JSON Lines, also called NDJSON): one complete JSON object per line. It streams, appends, and parallelizes beautifully, which is why 2025–2026 data infrastructure — from log pipelines to LLM training sets — standardized on it.
Spreadsheets hate it, though. Excel cannot open JSONL, and nested objects inside each line do not map to columns. This post shows the format, the two conversions that matter, and how to do both privately in your browser with RividTech.
JSON vs JSONL in 30 seconds
// users.json — one array, must parse whole file
[
{"id": 1, "email": "a@example.com", "tags": ["pro", "eu"]},
{"id": 2, "email": "b@example.com", "tags": ["free"]}
]
// events.jsonl — one object per line, streamable
{"id": 1, "email": "a@example.com", "tags": ["pro", "eu"]}
{"id": 2, "email": "b@example.com", "tags": ["free"]}- JSON array — great for small API responses; breaks on huge files and trailing commas.
- JSONL / NDJSON — great for logs, streams, datasets; read line-by-line, skip bad lines without losing the file.
- Same rule: pretty-print and validate with JSON Formatter before converting.
Step 1: preview and validate the lines
Paste a few lines into JSON Preview to see the table shape, and check JSON Formatter to catch the classic JSONL killers: a pretty-printed object spanning multiple lines, a trailing comma, or one corrupt line in 100k. For shell users, the equivalent check is jq for JSON Processing from the Terminal.
Step 2: flatten nested objects and arrays
Real JSONL nests: user.address.city, order.items[], metadata.model. Spreadsheets need flat columns, so expand with Flatten JSON:
{"id": 7, "user": {"email": "c@example.com", "plan": "pro"}, "tags": ["eu", "beta"]}
-- flatten -->
id | user.email | user.plan | tags.0 | tags.1
7 | c@example.com | pro | eu | betaDeep background with API examples: Flatten Nested JSON for Spreadsheets and CSV. In pandas, the same step is pd.read_json("events.jsonl", lines=True) plus pd.json_normalize — see How to Use Pandas for CSV and JSON Data Processing.
Step 3: convert JSONL to CSV, Excel, or SQL
- JSON to CSV — flattened records to a spreadsheet-ready table.
- JSON to Excel — straight to
.xlsxfor non-technical stakeholders. - JSON to SQL —
CREATE TABLE+INSERTfor Postgres, MySQL, SQLite. - JSON to TSV — when values contain commas that fight CSV.
Reverse direction when an API wants JSON back: CSV to JSON (safely — see How to Convert CSV to JSON Safely).
Step 4: clean the flattened table
Flattening exposes mess: inconsistent keys across lines, null vs missing vs empty string, mixed date formats. Run the standard pass:
- Validate CSV — ragged columns, bad emails/URLs/numbers.
- Remove Duplicates — retried events log twice; dedupe on event ID.
- Column Tools / Find & Replace — normalize labels and drop sparse columns.
- Data Stats — confirm uniques and null rates after flattening.
Large JSONL: sample, split, stream
JSONL's superpower is that you do not need the whole file. Take a 1,000-line slice with Sample Data to design the flatten mapping, validate the mapping on the sample, then apply it to the full export in chunks. If the flattened CSV is too big for Excel, split it with Split CSV — see Excel Won't Open My Large CSV.
Getting started
Preview, flatten, convert, validate: JSON Preview, Flatten JSON, JSON to CSV, and Validate CSV. Everything runs on your device — see our Privacy Policy.