JSONPath Benchmark

April 13, 2026 · View on GitHub

Benchmark JSONPath

This project benchmarks multiple JSONPath libraries written in Go. It evaluates performance in specific scenarios and offers guidance for selecting an appropriate library.

Contents

Overview

Results are generated via GitHub Actions for consistency and automation.

The benchmark focuses on the per-operation cost after initial setup is complete. Preparatory steps, such as parsing or preloading data, are excluded from the measurements. Instead, it emphasizes scenarios with intensive looping or query execution within the main operation.

Results may vary with factors such as input structure, query complexity, and runtime environment. Treat these benchmarks as a general reference and re-evaluate them periodically.

Notes on metrics:

  • Time: ns/op (lower is better)
  • Memory: B/op (lower is better)
  • Allocations: allocs/op (lower is better)

Libraries Benchmarked

The following libraries are included in this benchmark:

Simple Query Performance

JSONPath:

$.store.book[*].price

Summary:

  • Query features:
    • root selector ($)
    • child segments (name selectors)
    • wildcard selector ([*])
  • Compatibility: 10/10 (all libraries)
  • Fastest: AsaiYusuke/JSONPath

Performance Detail:

RankLibraryTime (ns/op)Memory (B/op)Allocations (allocs/op)Relative speed (fastest = 1x)
1AsaiYusuke/JSONPath (reuse)118.70001.00x
2AsaiYusuke/JSONPath166.206411.40x
3Yalp/JSONPath284.8016052.40x
4oliveagle/JsonPath376.8016053.17x
5ohler55/OjG (jp)533.70126444.50x
6theory/RFC 9535 JSONPath in Go745.20464206.28x
7PaesslerAG/JSONPath1336.008162911.26x
8vmware-labs/YAML JSONPath2071.0012406717.45x
9Spyzhov/Abstract JSON2517.009683021.20x
10bhmj/JSONSlice4132.003121334.81x

Simple query benchmark (ns/op)

Complex Query Performance

JSONPath:

$..book[?(@.price > $.store.bicycle.price)]

Summary:

  • Query features:
    • root selector ($)
    • descendant segment (..)
    • filter selector (?()) with comparison expression
    • path references (@ and $)
    • child segments (name selectors)
  • Compatibility: 6/10 (see Support Matrix)
  • Fastest: AsaiYusuke/JSONPath

Performance Detail:

RankLibraryTime (ns/op)Memory (B/op)Allocations (allocs/op)Relative speed (fastest = 1x)
1AsaiYusuke/JSONPath (reuse)1143.008021.00x
2AsaiYusuke/JSONPath1187.009631.04x
3theory/RFC 9535 JSONPath in Go3218.001408662.82x
4ohler55/OjG (jp)3995.006200373.50x
5Spyzhov/Abstract JSON15159.00546422213.26x
6bhmj/JSONSlice15672.0017283513.71x

Complex query benchmark (ns/op)

Support Matrix

LibrarySimple queryComplex query
AsaiYusuke/JSONPath (reuse)
AsaiYusuke/JSONPath
PaesslerAG/JSONPath
bhmj/JSONSlice
ohler55/OjG (jp)
oliveagle/JsonPath
Spyzhov/Abstract JSON
theory/RFC 9535 JSONPath in Go
vmware-labs/YAML JSONPath
Yalp/JSONPath

Conclusion

This benchmark compared several popular JSONPath libraries in Go and highlighted notable performance differences. Interestingly, the simple query showed a wider performance spread than the complex one, suggesting that implementation details and variations in query syntax handling can directly impact execution speed. Therefore, a practical evaluation should consider both feature support and raw performance. For selecting a library in production, we strongly recommend running benchmarks tailored to your own datasets and query patterns.

Reproduce Locally

Benchmarks are executed in GitHub Actions for consistency. For the exact steps and current outputs, check the Actions tab and the workflow logs. If you prefer to run locally, follow the same sequence defined in the workflow file (see .github/workflows/build.yml).

License

This project is distributed under the terms of the MIT License. See LICENSE for details.