SmartQueryTools

NDJSON vs CSV

NDJSON (Newline-Delimited JSON) and CSV are both line-oriented plain-text formats for tabular data, but they come from very different ecosystems. NDJSON is the format of streaming systems, event pipelines, and structured logs. CSV is the format of spreadsheets, databases, and data analysis. Knowing which to use depends on who produces your data and who consumes it.

What is NDJSON?

NDJSON (Newline-Delimited JSON), also known as JSON Lines, stores one JSON object per line. Each line is an independent, self-contained JSON document with no outer array wrapper. This structure makes NDJSON ideal for streaming — you can process records one line at a time without loading the entire file into memory, and append new records without rewriting the file.

NDJSON is used in log aggregation (Pino, Bunyan, Loguru), event streaming (Kafka consumers, Kinesis Firehose), Elasticsearch bulk indexing, and incremental database exports (change-data-capture). If you have ever tailed an application log and seen one JSON object per line, that is NDJSON.

What is CSV?

CSV (Comma-Separated Values) is a plain-text tabular format — one row per line, commas as delimiters, column names in the first row. Every analytics tool, database import utility, spreadsheet application, and programming language reads CSV by default. It is the universal interchange format for flat tabular data.

CSV's strength is its simplicity and tool support. A CSV file opens in Excel, reads in Python, loads into PostgreSQL with COPY, and parses in JavaScript without any configuration. The tradeoff is that CSV has no support for nested data, no native type information, and can require quoting when values contain commas.

NDJSON vs CSV: Key Differences

FeatureNDJSONCSV
StructureOne JSON object per lineFlat rows and columns
Nesting supportFull (nested objects and arrays)None
SchemaImplicit (per-record keys)First-row headers
Streaming / appendExcellent (line-by-line)Possible (append rows)
Spreadsheet supportNo — requires conversionNative
Database importRequires conversion or json functionsDirect (COPY, LOAD DATA)
File sizeVerbose (key names per record)Compact
Log / event systemsNativeUncommon
Human readableYesYes

When to use NDJSON

  • Application logs and structured event data emitted by logging frameworks
  • Streaming pipeline outputs from Kafka, Kinesis, or Pub/Sub consumers
  • Elasticsearch or OpenSearch bulk indexing (requires NDJSON format)
  • Incremental database exports where records are appended over time
  • Data with nested or variable structure that does not fit a flat schema

When to use CSV

  • Loading data into a relational database or data warehouse
  • Opening and analysing in Excel, Google Sheets, or a BI tool
  • Sharing flat tabular data — CSV is more compact than NDJSON for flat data
  • Feeding a pipeline or ETL tool that expects standard tabular input
  • Any workflow where maximum tool compatibility is required

Convert between NDJSON and CSV

Convert files instantly in your browser — no upload, no account, no server.

More format comparisons