Skip to content

Convert

NDJSON to CSV

NDJSON to CSV

Beta

Convert newline-delimited JSON (.ndjson, .jsonl) into a flat CSV in your browser. Nested keys become dot paths, the columns are the union of every row, a bad line is skipped and counted, and nothing is uploaded.

Use via API
  • Free, no sign-up
  • REST + MCP
  • Updated
  • Reviewed by Olgun Ozoktas

Parsed in your browser. We do not upload the file. One JSON object per line. Flatten writes nested keys as dot paths; null and a missing key both become an empty cell. A huge file is limited by tab memory, so use Download, not Copy, for a big output.

JSON Lines (NDJSON)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
CSV

The flat CSV will appear here..

Why Use Our NDJSON to CSV Converter?

API log dumps, search-index exports, streaming pipelines and fine-tune datasets write one JSON object per line. That format is called JSON Lines, NDJSON or JSONL. A spreadsheet, an upload form and a warehouse want a flat CSV instead, and a JSON array converter cannot read the line form because the whole file is not one JSON document. This page reads each line on its own, builds the header from every key it sees, flattens nested objects to dot paths, and writes RFC 4180 CSV. A line that is not a JSON object is skipped and named by its line number, so one broken record does not stop the export. The conversion runs in your browser; the file never leaves the tab.

JSON Lines is a text format with one JSON value per line, separated by line feeds. Log shippers, streaming exports and machine-learning datasets use it because a writer can append one record at a time and a reader can process one line at a time without loading the whole file. The trade-off is that the file as a whole is not valid JSON, so a converter that calls JSON.parse on the text fails on the second line. This page parses each line on its own.

The output is one CSV row per JSON object. The header is built from every key in every row, in first-seen order, so a key that appears only on line 900 still gets a column and earlier rows get an empty cell there. With Flatten, the default, a nested object becomes dot paths such as user.name and user.city, and an array becomes indexed keys such as tags[0] and tags[1], recursively. With JSON cell, a nested object or array is written as JSON text in one cell, quoted as CSV requires. null and a missing key both write an empty cell; numbers and booleans are written as text.

A line that is not valid JSON, or that is JSON but not an object, is skipped, counted, and listed as Line N with its file line number. The other lines still convert. A leading byte order mark is dropped, CRLF line ends are accepted, and blank lines are ignored. Quoting follows RFC 4180: a cell is quoted only when it holds the separator, a quote or a line break. The input cap is 10 MB. Nothing is uploaded; the file is parsed in your browser.

How it compares

A jq or Python one-liner does the same job on a workstation with those tools installed and a few minutes to write the flatten step. Online converters that upload the file hand a log of your users' requests to a server for a format change. This page reads the format with its line rule, builds a stable header from every row, names the lines it skipped, and keeps the file in the tab.

NDJSON to CSV Tips

  • The header is the union of every key across every line, in the order the keys first appear. A key that a row does not have is an empty cell, and so is null.
  • Under Flatten, an array becomes indexed columns: tags[0], tags[1]. A row with five tags creates five columns. Use JSON cell when you want the whole array in one cell.
  • An empty object or an empty array produces no column under Flatten. If a field is empty on every row, it does not appear.
  • Numbers and booleans are written as text, so 1.5 and true look the same in the CSV as in the JSON. The spreadsheet decides the type when it opens the file.
  • A file that starts with [ is a JSON array, not JSON Lines. The page refuses it and links to the JSON to CSV tool, which reads arrays.

Frequently Asked Questions

What is NDJSON, and how is it different from JSON?

NDJSON stands for newline-delimited JSON. JSON Lines and JSONL are other names for the same format. A file holds one JSON value per line, usually one object, and the lines are separated by line feeds. The file as a whole is not one JSON document, so a parser that reads the whole text fails after the first line. That is why the JSON to CSV tool cannot read it and this page exists.

How is the CSV header built?

Every key in every line goes into the header, in the order the keys first appear. If line 1 has id and name and line 2 adds email, the header is id, name, email, and line 1 gets an empty email cell. Nested keys are flattened first, so a user object with a name becomes the column user.name.

What happens to nested objects and arrays?

With Flatten, the default, nested keys become dot paths: user.name, user.address.city. Array items become indexed keys: tags[0], tags[1]. With JSON cell, a nested object or array is written as JSON text in one cell, for example {"code":"E42"}, and the CSV quoting doubles the inner quotes. An empty object or empty array produces no column under Flatten.

What happens to a line that is not valid JSON?

It is skipped, counted in the status line, and listed in the notes as Line N: invalid JSON, where N is the line number in the file. A line that is valid JSON but not an object, such as a number or an array, is listed as Line N: expected a JSON object. The other lines still convert. The notes list shows the first twenty.

Why does the page refuse my file and mention JSON to CSV?

The file starts with [ and parses as one JSON array. That is a JSON document, not JSON Lines, and the JSON to CSV tool reads it. The refusal is deliberate: reading an array as JSON Lines would give one row for the whole file, which is never what you want.

Are numbers, booleans and null kept?

They are written as text in the CSV: 1.5, true, false. null and a missing key both become an empty cell, because CSV has no null. Your spreadsheet decides the type when it opens the file. If you need the types back, CSV to NDJSON has a Coerce types option that turns them into JSON values again.

Can I open the CSV in Excel, Google Sheets or Numbers?

Yes. Google Sheets and Numbers read the UTF-8 file as it is. Excel on Windows sometimes shows accented characters wrongly in a plain UTF-8 CSV; turn on Excel BOM before you download and Excel reads it correctly. If your Excel expects semicolons, choose the semicolon separator.

Is my file uploaded anywhere?

No. The lines are parsed and the CSV is built in your browser, and no request carries the file. You can confirm that in the browser's network panel while converting. An API log holds request paths, user ids and sometimes tokens, and it stays on your machine.

How large a file can I convert?

The input cap is 10 MB of text. The conversion runs in the tab, so a file near the cap can keep the browser busy for a moment. For a large output, use Download rather than Copy; a very long text in the clipboard is slow to paste. For a batch or a script, the same converter is on the FindUtils API as ndjson_to_csv.

How do I go the other way, from CSV to NDJSON?

Use the CSV to NDJSON tool, or flip the direction toggle on this page. It reads the header as keys, writes one JSON object per line, and can turn true, false, null and plain numbers back into JSON values with Coerce types. It does not rebuild nested objects from dotted column names.

Rate This Tool

0/1000

Get Weekly Tools

Suggest a Tool