Home Docs Schema Formats Errors
Conduit

NDJSON

Newline‑Delimited JSON input and output

NDJSON (Newline‑Delimited JSON) is ideal for streaming, ingestion pipelines, and large datasets. Conduit supports NDJSON for both input and output. Each line is treated as a standalone JSON object.

NDJSON Input

To send NDJSON to Conduit, set the Content-Type header to application/x-ndjson.

{"title":"Example","created_at":"2024-01-01T00:00:00Z"}
{"title":"Another","created_at":"2024-01-02T00:00:00Z"}

Conduit parses each line as an independent JSON object and maps it into schema‑aware rows. NDJSON is especially useful for bulk inserts.

NDJSON Output

NDJSON output is selected when:

  • ?format=ndjson is used
  • Accept: application/x-ndjson is sent
  • The input format is NDJSON
GET /v1/books?format=ndjson

Example response:

{"id":1,"title":"Example","created_at":"2024-01-01T00:00:00Z"}
{"id":2,"title":"Another","created_at":"2024-01-02T00:00:00Z"}

Each line is a complete JSON object. NDJSON responses are flushed immediately when supported by the HTTP server.

NDJSON Schema Responses

Schema endpoints return NDJSON describing the table’s columns, types, and metadata.

GET /v1/schema/books?format=ndjson

Example:

{"name":"id","type":"INTEGER","pk":true,"autoincrement":true}
{"name":"title","type":"TEXT","nullable":false}
{"name":"created_at","type":"TEXT"}

NDJSON Error Responses

Conduit returns a consistent NDJSON error envelope for all error conditions. This structure matches JSON, XML, YAML, TOML, CSV, and CBOR.

Example NDJSON error:

{"error":{"title":"Resource Not Found","message":"The requested record does not exist.","status":404,
"documentation_url":"https://docs.conduit.dev/errors/not-found","details":["No record with ID 999 exists in table 'books'."]}}

The fields in the error envelope come directly from the ErrorSpec used by Conduit’s internal error system.

Format Negotiation

NDJSON is selected when:

  • ?format=ndjson is used
  • Accept: application/x-ndjson is sent
  • The input format is NDJSON
GET /v1/books?format=ndjson