# Read a JSON file

Acquire / file

read JSON, NDJSON

Page: <https://meridian.online/operations/read-a-json-file>

## Status

Runs as a SQL step.

arcform carries it as a `sql:` step today.

## The DuckDB step

read newline-delimited JSON

It reads the `orders` table the proofs share. Create it first:

```sql
CREATE TABLE orders AS SELECT * FROM (VALUES
  (1,  'Alice Ng',      'north', DATE '2026-01-03', 120.00, 'widget', 'a|b',   '{"channel":"web","items":[1,2]}'),
  (2,  'alice ng',      'north', DATE '2026-01-05',  80.50, 'gadget', 'b',     '{"channel":"shop","items":[3]}'),
  (3,  'Bob  Okafor',   'south', DATE '2026-01-05', 300.00, 'widget', 'a|c',   '{"channel":"web","items":[4,5,6]}'),
  (4,  'Carla Díaz',    'east',  DATE '2026-01-09',  NULL,  'gizmo',  NULL,    '{"channel":"web","items":[]}'),
  (5,  'Bob Okafor',    'south', DATE '2026-01-12',  45.25, 'gadget', 'c',     '{"channel":"phone","items":[7]}'),
  (6,  'Dev Patel',     'west',  DATE '2026-01-12', 510.00, 'widget', 'a',     '{"channel":"web","items":[8,9]}'),
  (7,  'Carla Diaz',    'east',  DATE '2026-01-20',  99.99, 'gizmo',  'b|c',   '{"channel":"shop","items":[10]}'),
  (8,  'Dev Patel',     'west',  DATE '2026-02-02', 510.00, 'widget', 'a',     '{"channel":"web","items":[8,9]}'),
  (9,  'Eve Larsen',    NULL,    DATE '2026-02-03',  15.00, 'gadget', NULL,    '{"channel":"web","items":[11]}'),
  (10, 'Alice Ng',      'north', DATE '2026-02-10', 220.00, 'gizmo',  'a|b|c', '{"channel":"phone","items":[12,13]}')
) t(order_id, customer, region, order_date, amount, product, tags, meta);
```

Then run the statement:

```sql
COPY orders TO '<your_scratch_dir>/orders.json' (FORMAT json);
CREATE TEMP TABLE result AS
SELECT count(*) AS n, sum(amount) AS total FROM read_json('<your_scratch_dir>/orders.json');
SELECT * FROM result;
SELECT CASE WHEN ((SELECT n = 10 AND total = 1900.74 FROM result)) THEN 'as expected' ELSE error('the JSON file did not read back as 10 rows totalling 1900.74') END AS verdict;
```

Replace `<your_scratch_dir>` with a directory of your own that you can write to before running the statement.

The statement writes `orders.json` itself, in `<your_scratch_dir>`.

It needs nothing installed beyond DuckDB itself.

## Variants

- Pick rows out with a path expression: Choose which parts of the document become rows and columns by JSONPath expressions.
- [Read change messages as inserts, updates and deletes](https://meridian.online/operations/read-a-json-file/read-change-messages-as-inserts-updates-and-deletes): Read JSON change-data-capture messages so each one becomes an insert, update or delete row.
- Walk a JSON value into key and value rows: Turn the members of a JSON value into one row per key, with its value, type and path.
- [Read newline-delimited JSON](https://meridian.online/operations/read-a-json-file/read-newline-delimited-json): Read a file holding one JSON object per line, as JSON Lines or NDJSON, into rows.
- [Read each JSON object as one value](https://meridian.online/operations/read-a-json-file/read-each-json-object-as-one-value): Read the file without unpacking it, giving one JSON value per object or document for later parsing.
- Read a JSON file into rows and columns: Read a JSON document or array of objects into a table, one row per object and one column per field.
- Read only the lines added since the last run: Read an append-only JSON file from where the previous run stopped, or as a stream.

## What other tools call it

Meridian's classification; an independent blind rating agreed on 86.2% of 312 rows (exact class, version 2).

- Azure Data Factory: [`JSON format (source)`](https://learn.microsoft.com/en-us/azure/data-factory/format-json) (read 2026-09-27)
- Apache DataFusion: [`JSON`](https://datafusion.apache.org/user-guide/features.html) (read 2026-09-27)
- DuckDB: `json_each` (read 2026-09-27)
- DuckDB: `json_tree` (read 2026-09-27)
- DuckDB: `read_json` (read 2026-09-27)
- DuckDB: `read_json_auto` (read 2026-09-27)
- DuckDB: `read_json_objects` (read 2026-09-27)
- DuckDB: `read_json_objects_auto` (read 2026-09-27)
- DuckDB: `read_ndjson` (read 2026-09-27)
- DuckDB: `read_ndjson_auto` (read 2026-09-27)
- DuckDB: `read_ndjson_objects` (read 2026-09-27)
- Duckle: [`JSON`](https://github.com/slothflowlabs/duckle/blob/f85f8960edfb6efbf4cb89d58a7b32e16df0e867/website/docs/components.html) (read 2026-09-25)
- Duckle: [`JSONL / NDJSON`](https://github.com/slothflowlabs/duckle/blob/f85f8960edfb6efbf4cb89d58a7b32e16df0e867/website/docs/components.html) (read 2026-09-25)
- Duckle: [`Spool (tail NDJSON)`](https://github.com/slothflowlabs/duckle/blob/f85f8960edfb6efbf4cb89d58a7b32e16df0e867/frontend/src/workflow-ui/palette-data.ts) (read 2026-09-25)
- EasyMorph: [`Import JSON from file`](https://help.easymorph.com/doku.php?id=transformations:importjson) (read 2026-09-27)
- AWS Glue: [`JSON (read)`](https://docs.aws.amazon.com/glue/latest/dg/aws-glue-programming-etl-format-json-home.html) (read 2026-09-27)
- Apache Hop: [`JSON Input`](https://hop.apache.org/manual/latest/pipeline/transforms/jsoninput.html) (read 2026-09-27)
- Apache Hop: [`JSON Normalize Input`](https://hop.apache.org/manual/latest/pipeline/transforms/jsonnormalizeinput.html) (read 2026-09-27)
- KNIME Analytics Platform: [`JSON Reader`](https://api.hub.knime.com/nodes/*MJ89ZgBFq7ZpdhvG?details=full) (read 2026-09-27)
- Apache NiFi: [`JsonPathReader`](https://nifi.apache.org/components/org.apache.nifi.json.JsonPathReader/) (read 2026-09-27)
- Apache NiFi: [`JsonTreeReader`](https://nifi.apache.org/components/org.apache.nifi.json.JsonTreeReader/) (read 2026-09-27)
- OpenRefine: [`JSON`](https://openrefine.org/docs/manual/starting#create-a-project-by-importing-data) (read 2026-09-27)
- Pentaho Data Integration: [`JSON Input`](https://docs.pentaho.com/pdia-data-integration/9.3-data-integration/pdi-transformation-steps-reference-overview) (read 2026-09-27)
- Polars: [`read_json`](https://docs.pola.rs/api/python/stable/reference/io.html) (read 2026-09-27)
- Polars: [`read_ndjson`](https://docs.pola.rs/api/python/stable/reference/io.html) (read 2026-09-27)
- Polars: [`scan_ndjson`](https://docs.pola.rs/api/python/stable/reference/io.html) (read 2026-09-27)
- Power Query M: [`Json.Document`](https://learn.microsoft.com/en-us/powerquery-m/accessing-data-functions) (read 2026-09-27)
- Apache SeaTunnel: [`Canal Format`](https://seatunnel.apache.org/docs/2.3.13/connectors/formats/canal-json) (read 2026-09-27)
- Apache SeaTunnel: [`Debezium Format`](https://seatunnel.apache.org/docs/2.3.13/connectors/formats/debezium-json) (read 2026-09-27)
- Apache SeaTunnel: [`Kafka source compatible kafka-connect-json`](https://seatunnel.apache.org/docs/2.3.13/connectors/formats/kafka-compatible-kafkaconnect-json) (read 2026-09-27)
- Apache SeaTunnel: [`MaxWell Format`](https://seatunnel.apache.org/docs/2.3.13/connectors/formats/maxwell-json) (read 2026-09-27)
- Apache SeaTunnel: [`Ogg Format`](https://seatunnel.apache.org/docs/2.3.13/connectors/formats/ogg-json) (read 2026-09-27)
- Talend: [`tFileInputJSON`](https://help.qlik.com/talend/en-US/components/8.0/json/json-component) (read 2026-09-27)
- Talend: [`tFileStreamInputJSON`](https://help.qlik.com/talend/en-US/components/8.0/json/json-component) (read 2026-09-27)
- VisiData: [`jsonl (loader)`](https://github.com/saulpw/visidata/blob/7609212ec2febafa9caba7183cbebfaf49627909/visidata/loaders/json.py#L33) (read 2026-09-23)
- VisiData: [`jsonla (loader)`](https://github.com/saulpw/visidata/blob/7609212ec2febafa9caba7183cbebfaf49627909/visidata/loaders/jsonla.py#L36) (read 2026-09-23)
- VisiData: [`jsonobj (loader)`](https://github.com/saulpw/visidata/blob/7609212ec2febafa9caba7183cbebfaf49627909/visidata/loaders/json.py#L29) (read 2026-09-23)
