Query and extract data from JSON using JSONPath expressions
Features
- Advanced Query Syntax: Support full JSONPath syntax including wildcards (*), recursive descent (..), array slicing ([start:end]), filters ([?(@.price < 10)]), and multiple path selectors
- Path Expression Templates: Pre-built templates for common queries: root access ($), direct child ($.key), array items ($.arr[*]), filtered items ($.arr[?(@.id)]), recursive search ($..key)
- Real-Time Preview: Execute queries instantly with syntax-highlighted JSON input and output, show matching paths, display result count, and highlight matched nodes in source JSON
- Result Export: Export query results as JSON (array or single value), CSV for tabular data, or formatted text with one-click copy and download options
Usage Guide
- Input JSON Data: Paste or upload JSON data you want to query
- Write JSONPath: Enter JSONPath expression or use templates for common patterns
- Execute Query: Run query to see matching results with syntax highlighting
- Export Results: Copy or download extracted data in your preferred format
Technical Details
JSONPath Syntax
JSONPath expressions start with $ (root object) and use dot notation ($.property) or bracket notation ($['property']) for access. Child nodes use . separator ($.store.book), arrays use [index] or [*] for all items. Array slicing [start:end:step] extracts ranges like [0:3] (first 3 items) or [-1] (last item). Recursive descent operator .. searches all levels: $..author finds all author properties regardless of nesting depth. Union operator [,] selects multiple items: $[0,2,5] gets specific array indices.
Filter Expressions
Filters use [?(@.condition)] syntax to select items matching criteria. @ represents current node in iteration. Comparison operators: ==, !=, <, <=, >, >=. Logical operators: && (and), || (or), ! (not). Examples: [?(@.price < 10)] selects items with price under 10; [?(@.category == 'fiction' && @.price < 20)] combines conditions. Regular expression matching: [?(@.name =~ /pattern/)] filters by regex. Filters can reference root with $ for comparisons across hierarchy: [?(@.price < $.maxPrice)].
Implementation Variants
JSONPath has multiple implementations with slight syntax variations: Goessner's original (JavaScript), Jayway (Java), jsonpath-ng (Python). Differences include filter operators (some use @ vs $), regex support, script expressions, and function extensions. Some implementations add functions like @.length, @.min(), @.max() for aggregation. Script expressions [(@.price * @.quantity)] enable calculations. Parent operator ^ and current path ~ provide context. Always check target implementation's documentation for supported features and syntax quirks.
Frequently Asked Questions
- Why does my JSONPath return no results?
- Ensure the path starts with $, indexes are valid, and field names match exactly. Test with a simpler path first, then refine.
- How do I search a key at any depth?
- Use recursive descent: $..author finds author across all nesting levels.
- How do I write filter expressions?
- Use [?(@.price < 10)]. @ refers to the current item. Combine conditions with && and ||, e.g. [?(@.category=='book' && @.price<20)].
- Empty vs null in results?
- Empty means no match; null means the matched value is null. Verify both the source JSON and your path expression.
- Performance tips for large JSON?
- Avoid excessive ..; narrow the search first, then filter. Consider chunking or preprocessing server-side for very large inputs.
Related Documentation
- JSONPath Specification - Goessner - Original JSONPath proposal and syntax definition
- JSONPath Online Evaluator - Interactive JSONPath tester with expression documentation
- RFC 9535 - JSONPath Standard - IETF standardization effort for JSONPath query language
- jsonpath-ng Documentation - Python JSONPath implementation with extended features
- Jayway JSONPath (Java) - Popular Java implementation with filter expressions