Skip to content

Convert

NDJSON CSV Converter

NDJSON CSV Converter

Beta

Convert NDJSON (JSONL) to CSV or CSV to NDJSON on one page. Nested keys flatten to dot paths, bad lines are named, and types coerce on request.

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

Converted in your browser. This page does not upload the file. NDJSON to CSV flattens nested keys to dot paths, and null and a missing key both become an empty cell. CSV to NDJSON uses the header row as the keys and does not rebuild nested objects from dotted names. 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..

How to Convert NDJSON to CSV and CSV to NDJSON Online

  1. Pick the direction at the top of the tool

    NDJSON to CSV or CSV to NDJSON. Switching moves the current output into the input, so a round trip takes one click.
  2. Drop the .ndjson, .jsonl or .csv file on the input panel, upload it, or paste the text

    The conversion runs as soon as the text arrives.
  3. For NDJSON to CSV, choose how nested values are written

    Flatten turns user.name and tags[0] into their own columns; JSON cell keeps a nested object or array as JSON text in one cell. Pick the separator your reader expects, and turn on Excel BOM if Excel shows accented characters wrongly.
  4. For CSV to NDJSON, leave Header row on so the first row becomes the keys

    The separator is detected from the header line. Turn on Coerce types only when the loader expects numbers and booleans; off, 007 and a phone number stay intact as strings.
  5. Read the status line and the notes

    rows, columns, skipped lines and renamed keys. Then download the result or copy it.

Common Use Cases

Open an API request log in Excel or Google Sheets and filter by status, path or user

Turn an Elasticsearch or OpenSearch hits dump into rows a report can count

Check a fine-tune .jsonl file in a spreadsheet before you train on it

Load a streaming export into a warehouse or a BI tool that reads CSV

Share a slice of log data with someone who has a spreadsheet and no shell

Turn a product sheet into the record-per-line file a bulk loader reads

Build a prompt and completion dataset for a fine-tune job from a spreadsheet

Feed a contacts or events export into a pipeline that reads JSON Lines

Why Use Our NDJSON 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 loader or a fine-tune job wants the reverse. This page does both. NDJSON to CSV reads each line on its own, builds the header from every key it sees, flattens nested objects to dot paths, writes RFC 4180 CSV, and names each line it skipped. CSV to NDJSON reads the CSV per RFC 4180, so a quoted comma or a line break inside a cell stays inside the value, and writes one JSON object per line with the header as keys; every value stays a string unless you turn on Coerce types. On this page the conversion runs in your browser and the file stays in 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 converts JSON Lines to CSV and CSV back to JSON Lines, and parses each line on its own.

NDJSON to CSV writes 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, and the other lines still convert.

CSV to NDJSON reads the CSV per RFC 4180 and writes one JSON object per line, in header order, with LF line ends. The header row becomes the keys: names are trimmed, an empty name becomes column_N, and a duplicate name gets a numeric suffix so no value is lost. The separator is detected from the header among comma, semicolon, tab and pipe, or set by hand. Every value is a string by default, because a CSV has no types and a wrong guess corrupts data silently. With Coerce types on, true and false become booleans, null and an empty cell become null, and a plain number becomes a JSON number; a number with leading zeros stays text, and an integer of 2^53 or more stays text so a 64-bit id keeps every digit. Dotted header names are not rebuilt into nested objects.

In both directions a leading byte order mark is dropped, CRLF line ends are accepted, blank lines are skipped, and quoting follows RFC 4180. The input cap is 10 MB. On this page nothing is uploaded: both directions run in your browser.

How it compares

A jq or Python one-liner, or a pandas script, does the same job on a workstation with those tools installed and someone to write the flatten step and the type rules. Online converters that upload the file hand a log of your users' requests, or a customer list, to a server for a format change. This page reads JSON Lines with its line rule and CSV per RFC 4180, builds a stable header from every row, makes the type decision one explicit switch, names the lines it skipped and the keys it renamed, and keeps the file in the tab.

NDJSON and CSV Conversion 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.
  • Coerce types turns true and false into booleans, null and an empty cell into JSON null, and a plain number into a JSON number. 007 stays the string 007, and an integer of 2^53 or more stays a string so no digit is lost.
  • Dotted header names such as user.name stay flat keys. The tool does not rebuild nested objects, so the key in the JSON is the text user.name.
  • An empty header cell becomes column_N. A duplicate header gets a suffix: the second a is a_2. The notes say which names changed.
  • A row with more values than the header keeps the first values and is named in the notes with its row number. The header is row 1.
  • The output has LF line ends and one trailing newline. .ndjson and .jsonl are the same format under two names.

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.

Does this page convert both NDJSON to CSV and CSV to NDJSON?

Yes. The direction toggle at the top of the tool switches between NDJSON to CSV and CSV to NDJSON, and switching moves the current output into the input, so a file can make the round trip. For a script, the two directions are two API tools: ndjson-to-csv and csv-to-ndjson on REST, ndjson_to_csv and csv_to_ndjson on MCP.

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, switch the direction to CSV to NDJSON and turn on Coerce types, which 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.

What is the difference between .ndjson and .jsonl?

None in the content. Both hold one JSON object per line with line-feed separators. .ndjson stands for newline-delimited JSON and .jsonl for JSON Lines. The download is named .ndjson; rename it to .jsonl if a loader checks the extension.

Why is every value a string in CSV to NDJSON?

A CSV carries no types, so 007, 1e5 and a phone number are all just text. Turning text into numbers by guessing is how a zip code loses its leading zero. Values stay strings unless you turn on Coerce types, and then only true, false, null, an empty cell and a plain number change.

What exactly does Coerce types change?

true and false become booleans. null and an empty cell become JSON null. A plain number such as 42, -3.5 or 1e3 becomes a JSON number. A number with leading zeros stays a string. An integer of 2^53 or more, for example a 64-bit id, stays a string so no digit is lost. 1.0 becomes the number 1.

Can I get nested objects from dotted column names?

No. A header user.name produces the flat key user.name. Rebuilding nested objects would need a rule for arrays and for keys that contain a dot, and a wrong rule changes data silently. If you need nested JSON, convert the flat JSON in a script that knows your schema.

How is the CSV separator detected?

The header line is split with a comma, a semicolon, a tab and a pipe, and the one that gives the most fields wins. A file that uses semicolons is read correctly without a setting. Pick the separator by hand when the header contains the other character inside a quoted name.

What happens to a row with the wrong number of values?

A row with more values than the header keeps the first values and is named in the notes with its row number; the header counts as row 1. A row with fewer values fills the missing keys with an empty string, or null when Coerce types is on. Blank lines are skipped and counted in the status line.

What if two header cells have the same name?

The second one gets a suffix: a and a_2, then a_3. An empty header cell becomes column_N with its position. The notes list every renamed key so you can fix the header in the sheet if you prefer.

Is my file uploaded anywhere?

Not on this page. In both directions the file is parsed and the result 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 on this page it stays on your machine. The REST API and MCP tool are a separate path: a call sends the input you include to FindUtils over HTTPS, where it is processed and the result returned. FindUtils does not store that input, and logs the request without its content.

How large a file can I convert?

The input cap is 10 MB of text in either direction. 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 converters are on the FindUtils API as ndjson_to_csv and csv_to_ndjson.

Rate This Tool

0/1000

Get Weekly Tools

Suggest a Tool