● PART · ORIGINAL LIBRARY · ACTIVELY MAINTAINED

jsonpathx

Modern, high-performance JSONPath for TypeScript. RFC 9535 compliant, jsonpath-plus compatible.

version
0.2.0
downloads
781/month
published
2026-11-17
license
MIT
deps
0
author
Afzal Ahmad
$ npm install @jsonpathx/jsonpathx

## overview

jsonpath and jsonpath-plus are no longer maintained. jsonpathx keeps that ecosystem alive: it implements the official JSONPath standard (RFC 9535), supports jsonpath-plus extensions and options, and is written TypeScript-first.

## features

  • RFC 9535 compliant
  • jsonpath-plus compatible
  • TypeScript-first types
  • Fluent builder API
  • values, paths, pointers, parents
  • LRU cache with TTL

## quick start

import { JSONPath } from '@jsonpathx/jsonpathx';

const titles = await JSONPath.query('$.store.book[*].title', data);
// ['Sayings of the Century', 'Moby Dick', 'The Lord of the Rings']

const cheap = await JSONPath.query('$.store.book[?(@.price < 10)]', data);

const paths = await JSONPath.paths('$.store.book[*].title', data);
// ['$.store.book[0].title', '$.store.book[1].title', …]

## fluent builder

const result = await JSONPath.create(data)
  .query('$.store.book[*]')
  .filter(book => book.price < 10)
  .sort((a, b) => a.price - b.price)
  .map(book => book.title)
  .take(5)
  .execute();

## extended syntax

featureexample
OR operator$.store.book | $.store.bicycle
grouping$.store.(book, bicycle)
XPath-style filter$..book[?~@.price<10].author
type selectors$.items[?(@number())]

## api reference

JSONPath.query(path, data, options?)

Returns matching values.

JSONPath.paths(path, data)

Returns normalized paths to each match.

JSONPath.pointers(path, data)

Returns JSON Pointers to each match.

JSONPath.parents(path, data)

Returns the parent of each match.

JSONPath.create(data)

Starts a chainable query: .query · .filter · .sort · .map · .take · .execute

full reference on the docs site ↗

## bench

## maintenance

Status: actively maintained · 8 published versions · benchmarks: bench/results.md in the repo · issues and PRs on GitHub.