SmartQueryTools

Convert CSV to NDJSON Online

Convert CSV files to NDJSON format directly in your browser. No upload required — your data never leaves your device.

About converting CSV to NDJSON

NDJSON, also called JSON Lines, puts one complete JSON object on each line with no enclosing array. Converting CSV to NDJSON is the usual step when records must go into a system that reads data a line at a time: BigQuery and Snowflake loads, mongoimport, jq pipelines, message queues, or a Python loop that never holds the whole file in memory.

The line structure is the point. You can split the output with split -l, sample it with head, or append new records later without rewriting the file. A pretty-printed JSON array cannot be handled that way, because it only becomes valid once the closing bracket has been read. The repeated keys make the file bigger than the CSV, but NDJSON compresses well, and BigQuery and Snowflake load gzipped files directly.

Most pitfalls come from the loaders rather than the format. Elasticsearch's _bulk endpoint needs an action line before each document, so this output is not a bulk request body as it stands. BigQuery reads the date strings ("2026-03-02") straight into DATE columns. Date-times use a space rather than a T ("2026-03-02 10:15:00"), which BigQuery accepts but stricter ISO 8601 parsers may reject.

Not sure which format you need? Read the NDJSON vs CSV comparison.

Worked example

A small orders export with an ID, a customer name, a date, an amount (one missing) and a true/false flag, converted with the default settings.

Input (CSV)

order_id,customer,order_date,amount,shipped
1001,Acme Ltd,2026-03-02,249.5,true
1002,Brightside Co,2026-03-02,1200,false
1003,Acme Ltd,2026-03-05,89.99,true
1004,Northwind,2026-03-07,,false

Output (NDJSON)

{"order_id":1001,"customer":"Acme Ltd","order_date":"2026-03-02","amount":249.5,"shipped":true}
{"order_id":1002,"customer":"Brightside Co","order_date":"2026-03-02","amount":1200,"shipped":false}
{"order_id":1003,"customer":"Acme Ltd","order_date":"2026-03-05","amount":89.99,"shipped":true}
{"order_id":1004,"customer":"Northwind","order_date":"2026-03-07","amount":null,"shipped":false}

What changes when you convert CSV to NDJSON

  • Each CSV row becomes a single line holding one compact JSON object. There are no commas between lines and no surrounding [ ].
  • Keys repeat on every line, taken from the CSV header, so the file is larger than the CSV.
  • Order 1004 is written with "amount":null, so every line has the same set of keys even when a field is empty.
  • Numbers and true/false values are unquoted. Dates are strings such as "2026-03-02".
  • Lines are separated by a line feed. The last line has no trailing newline.

Your file is processed locally in your browser and is never uploaded. The free limit is 50 MB per file; larger files work if your device has the memory for them.

Frequently Asked Questions

Can I send this file straight to the Elasticsearch _bulk API?

No. The bulk API expects an action line such as {"index":{}} before every document, plus a newline at the end. Add those lines with a short script, or use a client helper such as helpers.bulk() in elasticsearch-py, which accepts plain documents.

Why does wc -l show one line fewer than my row count?

wc counts newline characters, and the output has no newline after the last record. The record count is the wc -l result plus one. Readers of JSON Lines, such as jq, pandas.read_json(lines=True) and BigQuery, still read the last record.

Should I pick NDJSON or a JSON array?

Pick NDJSON when the consumer streams, appends or splits the data, or when the file is too big to parse at once. Pick the array format from CSV to JSON when a web app or config loader calls JSON.parse on the whole file.

What is NDJSON format?

NDJSON (Newline-Delimited JSON) stores one JSON object per line, making it easy to stream, append, and process incrementally.

Related Tools