Registry / storage / geojson-minifier

geojson-minifier

JSON →
library0.1.1jsnpmunverified

A utility to minify GeoJSON files by encoding geometries using delta and zigzag encoding, reducing file size by 2-4 times. Version 0.1.1 (last release appears to be stable). It provides both a CLI and an API for integration. Differentiator: simple encoding approach optimized for GeoJSON, unlike general compression tools like gzip. No recent updates; minimal maintenance.

npm install geojson-minifier
INSTALL
IMPORT
SIG · GEOJSON-MINIFIER
G
geojson-minifier
storagejavascriptv0.1.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

GeojsonMinifier
import GeojsonMinifier from 'geojson-minifier'
const GeojsonMinifier = require('geojson-minifier')
Package is ESM-only from v0.1.1? README shows CommonJS but likely provides ESM. Use default import.
pack
import GeojsonMinifier from 'geojson-minifier'; const minifier = new GeojsonMinifier(); minifier.pack(geojson)
GeojsonMinifier.pack(geojson) // must instantiate
pack and unpack are instance methods, not static.
unpack
import GeojsonMinifier from 'geojson-minifier'; const minifier = new GeojsonMinifier(); minifier.unpack(packed)
unpack is not a standalone function
Use same instance with same precision to correctly unpack.

Instantiate minifier with precision, pack a GeoJSON object, then unpack it back to original.

import GeojsonMinifier from 'geojson-minifier'; const minifier = new GeojsonMinifier({ precision: 6 }); const geojson = { type: 'FeatureCollection', features: [{ type: 'Feature', geometry: { type: 'LineString', coordinates: [[10.0, 20.0], [10.1, 20.1]] }, properties: {} }] }; const packed = minifier.pack(geojson); console.log('Packed size:', JSON.stringify(packed).length); const unpacked = minifier.unpack(packed); console.log('Unpacked:', JSON.stringify(unpacked));
Debug
Known issues
gotchaPrecision parameter must match between pack and unpack; otherwise decoding produces incorrect coordinates.
fix
Always use the same precision value when packing and unpacking.
affects: >=0.0.0
gotchaThe packed output is a JavaScript object, not a file or string. You must serialize manually if needed.
fix
Use JSON.stringify(packed) to write to file.
affects: >=0.0.0
deprecatedCLI usage shown in README may not work in all environments due to Node.js path issues.
fix
Use npx geojson-minifier or install globally.
affects: >=0.0.0
gotchaPackage may not support all GeoJSON geometry types (e.g., GeometryCollection) fully.
fix
Test with your specific GeoJSON structure before production use.
affects: >=0.0.0
Errors
Common errors & fixes
TypeError: GeojsonMinifier is not a constructor
Using CommonJS require but package is ESM-only, or incorrect import.
fix
Use ES module import: import GeojsonMinifier from 'geojson-minifier';
Error: Invalid GeoJSON object
Passing a non-standard GeoJSON or a string instead of an object.
fix
Parse JSON string first: JSON.parse(geojsonString).
Error: precision must be a number
Precision option omitted or not numeric.
fix
new GeojsonMinifier({ precision: 6 }) or any integer.
Upgrade
Version history
0.1.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
19 hits · last 30 days
node
18
Resources
geojson-minifier — npm install geojson-minifier · libregistry