Enter a JSONPath expression to extract matching values from your JSON:

Loading...
Loading...

What is JSONPath?

JSONPath is XPath for JSON—a query language that lets you extract values from JSON documents using path expressions. Instead of writing loops to find data, you write a single expression like $.users[*].email to get all user emails.

Syntax Quick Reference

ExpressionDescriptionExample
$Root object$ → entire document
.Child property$.store → store object
..Recursive descent (find anywhere)$..price → all prices
[n]Array index$.items[0] → first item
[*]All elements$.items[*] → all items
[-1]Last element$.items[-1] → last item
[0:3]Array slice$.items[0:3] → first 3 items
[?(@.x)]Filter expression$..book[?(@.price<10)]

Working Example

Consider this API response:

{
  "store": {
    "name": "TechMart",
    "products": [
      { "id": 1, "name": "Laptop", "price": 999, "inStock": true },
      { "id": 2, "name": "Mouse", "price": 29, "inStock": true },
      { "id": 3, "name": "Keyboard", "price": 79, "inStock": false },
      { "id": 4, "name": "Monitor", "price": 299, "inStock": true }
    ],
    "location": {
      "city": "San Francisco",
      "country": "USA"
    }
  }
}

Example Queries

QueryResult
$.store.name"TechMart"
$.store.products[*].name["Laptop", "Mouse", "Keyboard", "Monitor"]
$..price[999, 29, 79, 299]
$.store.products[0]{"id": 1, "name": "Laptop", ...}
$.store.products[-1].name"Monitor"
$.store.products[0:2].name["Laptop", "Mouse"]
$.store.products[?(@.price<100)].name["Mouse", "Keyboard"]
$.store.products[?(@.inStock==true)].name["Laptop", "Mouse", "Monitor"]
$..city["San Francisco"]

Filter Expressions

Filters ([?()]) let you select elements that match a condition. Use @ to reference the current element:

  • [?(@.price > 100)] — Price greater than 100
  • [?(@.price <= 50)] — Price 50 or less
  • [?(@.inStock == true)] — In stock items
  • [?(@.name)] — Has a name property
  • [?(@.tags[*] == "sale")] — Has "sale" in tags array

Real-World Use Cases

Extract All Emails from API Response

$..email

Finds every email field anywhere in the document—useful when you don't know the exact structure.

Get Failed Items from a Batch Response

$.results[?(@.status == "failed")]

Filters to only the items that failed processing.

Find Products in a Price Range

$.products[?(@.price >= 10 && @.price <= 50)]

Combines multiple conditions with &&.

Get Specific Fields from Nested Arrays

$.orders[*].items[*].sku

Extracts SKUs from all items in all orders.

Pro Tips

  • 💡 Start with $ and build up — Test $.storebefore trying $.store.products[?(@.price>100)].name
  • 💡 Use .. when you're not sure of the path$..id finds all IDs regardless of nesting depth
  • 💡 Filter returns an array — Even if one item matches, you get [item] not item
  • 💡 Dot notation vs bracket notation$.store.name equals $['store']['name']. Use brackets for special characters: $['my-field']

JSONPath vs Alternatives

ToolBest For
JSONPathQuick extraction, language-agnostic, browser-friendly
jqCommand-line processing, complex transformations
JavaScriptWhen you need full programming logic

Related Tools