Registry / storage / geojson-schema

geojson-schema

JSON →
library1.0.5jsnpmunverified

Generates standalone JSON Schema documents for GeoJSON object types (Feature, Point, Polygon, etc.) as defined by RFC 7946. Current stable version is 1.0.5, released infrequently. Each schema is self-contained (no $ref dependencies), allowing consumers to fetch only what they need. Key differentiator: provides complete, non-referenced schemas ideal for offline or selective validation. Cannot validate linear ring closure or right-hand rule, requiring custom logic. Used for validating GeoJSON structures in any JSON Schema compliant validator.

npm install geojson-schema
INSTALL
IMPORT
SIG · GEOJSON-SCHEMA
G
geojson-schema
storagejavascriptv1.0.5
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.

PointSchema
✓ const PointSchema = require('geojson-schema/Point.json')
✗ import { PointSchema } from 'geojson-schema'
Package provides raw JSON files. Use require or fetch. No ESM exports.
FeatureSchema
✓ const FeatureSchema = require('geojson-schema/Feature.json')
✗ import FeatureSchema from 'geojson-schema/Feature.json'
Use CommonJS require. ESM import with assert { type: 'json' } may work in some bundlers.
GeoJSONSchema
✓ const GeoJSONSchema = require('geojson-schema/GeoJSON.json')
✗ const GeoJSONSchema = require('geojson-schema')
Main entry point includes all types via $ref, but individual files are preferred.

Validates a GeoJSON Point using AJV with the standalone Point schema from geojson-schema.

const Ajv = require('ajv'); const ajv = new Ajv(); const PointSchema = require('geojson-schema/Point.json'); const validate = ajv.compile(PointSchema); const validPoint = { "type": "Point", "coordinates": [102.0, 0.5] }; const invalidPoint = { "type": "Point", "coordinates": [102.0] }; console.log(validate(validPoint) ? 'Valid' : 'Invalid'); // Valid console.log(validate(invalidPoint) ? 'Valid' : 'Invalid'); // Invalid console.log(JSON.stringify(validate.errors));
Debug
Known issues
gotchaCannot validate linear ring closure or right-hand rule.
fix
Implement custom validation for closed rings and right-hand rule as per RFC 7946.
affects: >=1.0.0
gotchaSchemas are self-contained; avoid combining them if you need cross-references.
fix
Use individual schemas directly; do not rely on $ref to other schemas.
affects: >=1.0.0
gotchaPackage exports raw JSON files, not JavaScript modules. ESM import may require assertions or bundler configuration.
fix
Use CommonJS require or configure your bundler to handle JSON imports.
affects: >=1.0.0
Errors
Common errors & fixes
Cannot find module 'geojson-schema'
Importing the package as a module without specifying a JSON file path.
fix
Use require('geojson-schema/Point.json') with the specific schema file.
Error [ERR_REQUIRE_ESM]: require() of ES Module not supported
Using ESM imports with Node.js and assuming the package exports JavaScript modules.
fix
Use require() with the .json extension, or if using ESM, use createRequire or import assertion.
Upgrade
Version history
1.0.5latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
23 hits · last 30 days
node
22
OpenAI (training)
1
Resources
geojson-schema — npm install geojson-schema · libregistry