Switch tool

JSONPath Tester

Query JSON with JSONPath expressions and preview matched values live

JSON input
0 chars · 1 lines
Matched values
0 chars · 1 lines

How to use

Purpose

Online JSONPath tester. Apply JSONPath expressions (XPath-like) to extract data subsets from JSON. Supports standard JSONPath ($..*[][?()]), JSONPath Plus extensions (@parent / @type / @root), filters ([?(@.age > 18)]), slicing ([0:5]), recursive descent (..). Side-by-side JMESPath dialect comparison. Common for extracting fields from complex API responses, writing API doc examples, config-file path expressions, learning jq / jmespath. All queries run locally.

Steps

  1. Paste JSON on the left
  2. Type JSONPath expression in the middle (starts with $)
  3. Right pane shows matches in real time
  4. Common expressions: $..book[*] (all books), $..book[?(@.price<10)] (cheap books)
  5. Syntax highlighting: parts colored (path / filter / slice)
  6. Syntax error: invalid expression highlights the position
  7. Dialect switch: JSONPath (standard), JSONPath Plus, JMESPath
  8. Code snippet: JS / Python / Java calls using the matching JSONPath library

FAQ

JSONPath vs JMESPath?
JSONPath (2007, Stefan Goessner): more XPath-like, $.store.book[*].author, used by AWS and many jq-like tools. JMESPath: AWS official standard, store.book[*].author (no $), stronger pipes and functions (sort_by, max_by). In practice: jq is the most common CLI (a separate syntax — most powerful but steepest curve). JSONPath / JMESPath are easier to embed in code.
How to use filter [?(@.age > 18)]?
@ refers to the current node. Example: $..users[?(@.age > 18)] finds users older than 18. Operators: > < >= <= == != && ||. String matching: [?(@.name == "Tom")] strict equality; some libs support regex [?(@.name =~ /tom/i)] (JSONPath Plus extension).
$.. vs $.*?
$.. (recursive descent): matches at all levels. $..price finds all price fields regardless of nesting depth. $.* (single-level wildcard): only matches direct children of the current node. $.store.* matches direct children of store (book / bicycle), not recursive.
How to select last / second-to-last array element?
Last: $..book[-1:] or $..book[(@.length-1)]. Second to last: $..book[-2:-1]. First 3: $..book[:3]. Items 2 to 4: $..book[1:4]. Slicing syntax similar to Python.
Can JSONPath modify JSON?
Pure JSONPath is read-only (query language). Modification needs dedicated libraries: jsonpath-plus has jsonpath.value(json, path, newValue). Complex modifications: use jq CLI: `jq '.users[].active = true'`. This tool is for query debugging — modify via code or jq.

Use cases

  • API response field extraction: complex JSON → specific fields
  • API docs: example JSON + extraction path for consumers
  • Config file paths: JSONPath expressions to locate config items
  • JSON log analysis: filter logs by field
  • jq CLI prep: test JSONPath here before converting to jq

Use cases

API field extraction, doc examples, config paths, JSON log analysis, jq preparation. Backend, frontend, ops, data analysts. Multi-dialect, filters, slicing, code snippet generation are the differentiators.