Skip to content

jsonpathxModern JSONPath with a JS engine

Benchmark-tracked JSONPath with TypeScript-first DX

jsonpathx

Quick Example โ€‹

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

const data = {
  store: {
    book: [
      { title: 'Sayings of the Century', price: 8.95 },
      { title: 'Moby Dick', price: 8.99 },
      { title: 'The Lord of the Rings', price: 22.99 }
    ]
  }
};

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

// Filter by condition
const cheapBooks = await JSONPath.query('$.store.book[?(@.price < 10)]', data);
// [{ title: 'Sayings of the Century', price: 8.95 }, { title: 'Moby Dick', price: 8.99 }]

// Fluent API
const result = await JSONPath.create(data)
  .query('$.store.book[*]')
  .filter(book => book.price < 10)
  .map(book => book.title)
  .execute();
// ['Sayings of the Century', 'Moby Dick']

Installation โ€‹

bash
npm install @jsonpathx/jsonpathx

Why jsonpathx? โ€‹

Performance โ€‹

jsonpathx tracks performance against jsonpath-plus and jsonpath across real workloads. In the current benchmark suite, jsonpathx wins the majority of queries (44/48). Results still vary by query; see the benchmarks page for current numbers.

Modern TypeScript โ€‹

Built from the ground up with TypeScript, providing full type safety, excellent IDE support, and a delightful developer experience.

Feature Rich โ€‹

  • All RFC 9535 JSONPath features
  • Extended selectors (type selectors, parent navigation)
  • Multiple result types (values, paths, pointers, parents)
  • Query caching for repeated queries
  • Fluent QueryBuilder API
  • Path utility functions

Battle Tested โ€‹

With a growing test suite covering edge cases, error handling, and performance scenarios, jsonpathx is production-ready.

Comparison โ€‹

Featurejsonpathxjsonpath-plusjsonpath
PerformanceVaries by query (see benchmarks)Varies by queryVaries by query
TypeScriptBuilt-in typings.d.ts onlyNo
EngineJSJSJS
Fluent APIYesNoNo
Type SelectorsYesNoNo
Parent NavigationYesYesNo
Result Types7 types4 types1 type
CachingBuilt-in (opt-in)NoNo
Tests40+ (current suite)UnknownUnknown
Bundle SizeMeasured via npm run sizeSee upstreamSee upstream

Next Steps โ€‹

Released under the MIT License.