What it reads
Treat each line as a record as soon as it arrives.
NDJSON is deliberately line-oriented, which makes it a practical format for logs, exports, and large table streams. NDJSONLoader turns those lines into bounded batches.
Formats
NDJSON, JSONL, and LDJSON
Input
One JSON value per line
Output
Row tables or Arrow tables
APIs
Atomic and incremental loading
Detailed guide
NDJSONLoader reference
The sections below cover format metadata, atomic and streaming usage, Arrow output, and parsing options.
Streaming loader for NDJSON encoded files and related formats (LDJSON and JSONL).
| Characteristic | Value |
|---|---|
| File Extension | .ndjson, .jsonl, .ldjson |
| Media Type | application/x-ndjson, application/x-ldjson, application/json-seq |
| File Type | Text |
| File Format | NDJSON, LDJSON, JSON Text Sequences |
| Data Format | Tables |
| Supported APIs | load, parse, parseSync, parseInBatches |
NDJSONLoader loads NDJSON data as native Apache Arrow RecordBatch objects when streaming. Set ndjson.shape: 'object-row-table' or ndjson.shape: 'array-row-table' for row-oriented batches.
Usage
import {NDJSONLoader} from '@loaders.gl/tables/json';
import {load} from '@loaders.gl/core';
const data = await load(url, NDJSONLoader, {ndjson: options});
The NDJSONLoader supports streaming NDJSON parsing, in which case it will yield "batches" of rows, where each row is a parsed line from the NDJSON stream.
import {NDJSONLoader} from '@loaders.gl/tables/json';
import {loadInBatches} from '@loaders.gl/core';
const batches = await loadInBatches('ndjson.ndjson', NDJSONLoader, {
ndjson: {shape: 'object-row-table'}
});
for await (const batch of batches) {
// batch.data will contain a number of rows
for (const obj of batch.data) {
// Process obj
...
}
}
Set ndjson.shape: 'arrow' for a native Arrow Table from atomic loads and native RecordBatches from batch loads.
import {load, loadInBatches} from '@loaders.gl/core';
import {NDJSONLoader} from '@loaders.gl/tables/json';
const table = await load(url, NDJSONLoader, {
ndjson: {shape: 'arrow'}
});
const batches = await loadInBatches('ndjson.ndjson', NDJSONLoader, {
batchSize: 1000,
ndjson: {shape: 'arrow'}
});
NDJSONLoader also accepts the deprecated json.shape alias for shape selection. ndjson.shape takes precedence, and schema/recovery options remain under ndjson.*. In Arrow mode, ndjson.schema accepts either a loaders.gl Schema or Apache Arrow Schema. ndjson.arrowConversion has the same strict-by-default recovery policy as JSONTableLoader: type mismatches, missing fields, and integer conversion issues throw unless configured to recover, and extra fields throw unless configured to drop. GeoJSON feature rows are converted as generic nested JSON rows; use GeoJSONLoader with geojson.shape: 'arrow' for GeoArrow WKB output.
Data sources
Pass NDJSONLoader to createDataSource()
to open a URL or Blob for table queries. Use load() to parse the input into a table.
Data Format
Parsed NDJSONLoader batches are of the format.
{
// standard batch payload
data: any[] | any;
bytesUsed: number;
batchCount: number;
}
Each element in the data array corresponds to a line (Object) in the NDJSON data.
Options
Supports the table category options such as batchSize.
| Option | Type | Default | Description |
|---|---|---|---|
ndjson.shape | string | 'arrow' | Requested table shape. Supported values are 'arrow', 'object-row-table', and 'array-row-table'. |
ndjson.schema | Schema | arrow.Schema | undefined | Optional schema used when ndjson.shape is 'arrow'. |
ndjson.arrowConversion | object | strict recovery policy | Optional Arrow conversion policy. Supports onTypeMismatch, onMissingField, onExtraField, integerConversion, and logRecoveries. |
ndjson.arrowConversion.viewTypes | 'never' | 'prefer' | 'require' | 'never' | Controls whether supported Arrow runtimes emit BinaryView and Utf8View, with fallback in 'prefer' mode. |
json.shape | `'arrow' \ | 'object-row-table' \ | 'array-row-table'` |
Worker batches
This loader supports stateful worker batch parsing with core.worker: true, cancellation via
signal, and decoded-row progress via onProgress. See JSON worker batches
for streaming behavior, schemas, backpressure, and Node/custom-worker options.
Arrow tables return as directly transferred column buffers. Row tables and container metadata return as binary JSON frames decoded on the caller, preserving heterogeneous values without Arrow coercion. Decoded row objects are never structured-cloned across the worker boundary.
