CSV — row-oriented
CSV is naturally row-oriented: each line maps to a record of delimited fields. Schema is implied by header rows or documentation rather than embedded types; structural variants can be tolerated but may require consumer agreements.
This worksheet helps engineers and designers choose between CSV, a single JSON array, and newline‑delimited JSON (NDJSON) when exchanging tabular or streamed record data by clarifying streamability, schema expression, tooling, and error‑isolation trade‑offs.
The vertical rail to the left numbers nine compact sections. Each numbered section presents three parallel "specimens"—CSV, JSON array, NDJSON—focused on the criterion named in the section heading. Use the selector below to highlight the lane and the related row in the synthesis card when you have a single primary constraint.
CSV is naturally row-oriented: each line maps to a record of delimited fields. Schema is implied by header rows or documentation rather than embedded types; structural variants can be tolerated but may require consumer agreements.
A single JSON array is a self-contained document of records. Schema can be expressed with JSON Schema or a shared contract, but the whole array is delivered as one atomic payload by typical transports.
NDJSON writes one JSON record per newline. Each line is a complete JSON value, enabling record-by-record handling; schemas are per-record or shared out-of-band similar to CSV but with explicit typing in JSON values.
CSV is efficient to stream line by line but needs careful handling of quoted fields and line breaks within fields; incremental parsing is common in tooling but must respect quoting rules.
A JSON array normally requires the consumer to see the full document boundary before extracting records. This simplifies framing but makes true streaming and incremental processing harder without additional framing conventions.
NDJSON supports incremental parsing: consumers can process, persist, or forward each JSON line as it arrives. Framing is simple (newline) and works well for streaming pipelines and log-like flows.
When a CSV row is malformed, consumers can often skip or log the offending line and continue; however, parsing ambiguity (e.g., unmatched quotes) can block recovery unless robust parsers are used.
A single malformed element or a syntax error typically invalidates the entire array document; recovery requires partial reads or reparsing strategies and is thus harder than line-delimited formats.
Because each line is an independent JSON value, a parse error affects one record only; consumers can log, skip, or quarantine the bad line and continue processing the stream.
CSV is widely supported by spreadsheets and simple editors, making it the default for human-facing exports. It is concise but loses typed structure without conventions for nested data.
JSON arrays are friendly to document-oriented tools, validators, and schema processors. Less convenient for direct spreadsheet editing, but well-suited when consumers expect structured JSON.
NDJSON is handy for line-oriented tooling, command-line filters, and simple stream processors. It is editable in plain text but less friendly than CSV for spreadsheet workflows.
For log-style, append-only streams where individual records may carry nested fields, NDJSON encodes structured values directly and isolates errors per record; CSV is lighter and spreadsheet-compatible but needs escaping conventions for nested or quoted values.
APIs that return a small-to-medium batch where consumers expect a single payload often prefer a JSON array for atomic delivery; for very large batches or streaming processing, NDJSON enables incremental consumption and partial progress reporting.
| Criterion | CSV | JSON array | NDJSON |
|---|---|---|---|
| Orientation | Row/field grid; light and compact. | Document of records; atomic payload. | Line-delimited JSON records; explicit values. |
| Schema | Implied by headers or docs; limited typing. | Best for schema-driven validation tools. | Schema out-of-band or per-record; typed values possible. |
| Streaming | Streamable but quoting complicates framing. | Requires buffering; not ideal for streams. | Designed for incremental consumption. |
| Error isolation | Line-level skip often possible; parser-dependent. | Single failure can invalidate whole document. | Per-line isolation; easy to skip or quarantine bad records. |
| Tooling | Excellent spreadsheet support. | Rich JSON tooling and validators. | Good for logs, CLI tools, and streams. |
| Human editing | Easy in spreadsheets and editors. | Readable as JSON but less spreadsheet-friendly. | Editable in text editors; not spreadsheet-native. |
| Edge cases | Nested data and multiline fields are awkward. | Complex structures are supported naturally. | Supports nested JSON per line; newline framing matters. |