Skip to main content



Streaming writer for GeoJSON encoded files.

File Extension.geojson
Media Typeapplication/geo+json
File TypeText
File FormatGeoJSON
Data FormatClassic Table
Supported APIsencode, encodeSync, encodeΓ“InBatches


For simple usage, you can encode a table into a JSON "file" atomically:

import {GeoJSONWriter} from '';
import {encode} from '';

const data = await encode(url, GeoJSONWriter, {json: options});

Streaming and JSON paths​

For larger files, GeoJSONWriter supports streaming JSON parsing, in which case it will yield "batches" of rows from one array.

import {GeoJSONWriter} from '';
import {encodeInBatches} from '';

const batches = await encodeInBatches('geojson.json', GeoJSONWriter, {json: {jsonpaths: ['$.features']}});

for await (const batch of batches) {
// will contain a number of rows
for (const feature of {
switch (feature.geometry.type) {
case 'Polygon':

To parse a stream of GeoJSON, the user can specify the options.json.jsonpaths to stream the features array.

If no JSONPath is specified the loader will stream the first array it encounters in the JSON payload.

Data Format​

Encoded batches are array buffers or strings


Supports table category options such as batchType and batchSize.

json.table[Website]booleanfalseParses non-streaming JSON as table, i.e. return the first embedded array in the JSON. Always true during batched/streaming parsing.
json.jsonpaths[Website]string[][]A list of JSON paths (see below) indicating the array that can be streamed.


A minimal subset of the JSONPath syntax is supported, to specify which array in a JSON object should be streamed as batchs.


  • No support for wildcards, brackets etc. Only paths starting with $ (JSON root) are supported.
  • Regardless of the paths provided, only arrays will be streamed.


This loader is based on a fork of dscape's clarinet under BSD 2-clause license.