Australian Jeevitham TECHDeveloper tools

Tech / JSONPath Tester

JSONPath Tester

Try a JSONPath expression against your JSON and see every matching value and where it sits in the document.

JSONPath expression

Syntax

$ the whole document
.name a child by key
['a b'] a key with spaces
[0] an array item
[-1] the last item
[*] every child
..name search at any depth
[0:2] a slice (start:end:step)
[0,2] several items
[?(@.a > 1)] a filter
&& || ! combine filters
[?(@.a)] key exists

About JSONPath

JSONPath picks values out of a JSON document, the way a file path picks a file out of folders. It was standardised in 2024 as RFC 9535, and it is used by tools such as kubectl and many testing and automation tools.

With this JSON - {"store":{"book":[{"title":"A","price":8},{"title":"B","price":12},{"title":"C","price":9.5}],"bicycle":{"price":200}}} - these paths give:

PathResult
$.store.book[*].title"A", "B", "C" - every book title
$.store.book[0].title"A" - the first book
$.store.book[-1].title"C" - the last book
$..price8, 12, 9.5, 200 - every price at any depth
$.store.book[?(@.price < 10)].title"A", "C" - books under 10

JSONPath or jq?

jq is a command-line program with its own, more powerful language for changing JSON. JSONPath only selects values, but it is simpler and built into many libraries and tools, so it is often the quicker choice for finding data.

Tips

  • Use ['key name'] for keys with spaces or dashes.
  • .. searches the whole document, so it can match more than you expect - check the Paths list to see where each match came from.

Everything runs in your browser, and your JSON is not uploaded.