DevTools Logo

JSONata Playground

JSONata Playground

Query and reshape JSON with a zero-dependency JSONata subset — entirely in your tab.

Runs in your browser
Try an example

Input

16 lines · 178 chars

Result

2 chars
20

Zero-dependency subset · path navigation, predicates, bindings and documented built-ins only. Error at 1:20.

Details

A lightweight JSONata workbench built without an external engine. It supports root and context paths, dot navigation, wildcards, zero-based indexes, flattening, simple predicates, JSON bindings and a documented set of string, numeric, aggregation, array and object functions. Every syntax or runtime error carries a JSONata-style code and an expression position, and undefined results render as null with a no-match chip. Samples, expressions and bindings never leave the browser tab.

More examples

Group totals

$sum(orders.amount)

Project an amount from every order in the sequence and sum the numbers.

Filter and join

$join(orders[amount > 5].item, ', ')

Filter with a numeric predicate, project the item field, then join the matches.

Bindings

users[role = $wanted].name

Define $wanted in the bindings JSON editor; values are parsed as JSON, never concatenated into the expression.

Examples

Group totals

Input
$sum(orders.amount)
Output
20

A path projects amounts from each array element; $sum reduces the sequence.

Filter and join

Input
$join(orders[amount > 5].item, ', ')
Output
book

A numeric predicate filters the orders before the item field is projected.

Bindings

Input
users[role = $wanted].name
Output
Ada

$wanted comes from the parsed bindings JSON, not from expression text.

About this tool

JSONata Playground is a small, local workbench for the JSONata query language. Paste a sample document, type an expression and see the result immediately, with syntax and runtime errors carrying a code and expression position instead of a silent blank pane.

This build implements a documented zero-dependency subset: root and context paths, dot navigation, wildcards, array indexes, flattening, simple predicates, JSON bindings and built-ins for aggregation, strings, arrays and objects. Bindings are parsed as JSON and resolved through a variable table — no eval and no string concatenation.

It is deliberately not a full JSONata engine. Tagged expressions, sort evaluators, regex functions, recursion and higher-order signatures outside the reference panel are out of scope; the function reference lists exactly what is implemented so the tool never promises features it cannot run.

What this tool does not do

  • This is a zero-dependency subset, not a complete JSONata implementation.
  • Object constructors, regex functions, recursion, sort evaluators and function chaining are unsupported.
  • Predicates support simple field comparisons against literals or bindings, not arbitrary expressions.
  • Samples are capped at 2 MB and expressions at 50 KB; evaluation is synchronous and has no cancellation timer.
  • Errors from nested function arguments report positions relative to that argument list.

How to use this tool

  1. Load an example

    Pick a gallery example such as Group totals, Filter and join or Bindings to seed the sample, expression and bindings editors.

  2. Edit the sample

    Paste JSON into the Sample JSON pane. BOM and CRLF are handled; invalid JSON produces a pane error and keeps the expression intact.

  3. Write an expression

    Use paths like orders.amount, predicates like orders[amount > 5] and functions like $sum(...) or $join(..., ', ').

  4. Add bindings

    Enter a JSON object such as {"wanted": "admin"} and reference its keys as $wanted in the expression.

  5. Explore the reference

    Open Functions, search by name or description and click an entry to insert its signature at the cursor.

Use cases

Learning JSONata

Try path, filter and function syntax against realistic sample documents without installing anything.

API response shaping

Prototype a projection over a pasted JSON payload before moving it into application code.

Debugging expressions

See the exact code and position for an unknown function or an unterminated bracket.

Teaching

Use the bundled examples to demonstrate aggregation, mapping, sorting and bindings.

Supported subset

SyntaxMeaning
$ / a.b / a.*Root document, child navigation, all children
a[0] / a[]Zero-based index / flatten one level
a[field = value]Predicate filter with =, !=, >, <, >=, <=
$sum / $count / $avg / $min / $maxNumeric aggregation
$map / $sort / $distinct / $keys / $values / $mergeArray and object helpers
$string / $number / $join / $uppercase / $lowercase / $trim / $substringString and scalar helpers

Undefined results render as null with a no-match chip; results above 256 KB skip pretty printing.

Common mistakes

Mistake:Expecting the full JSONata language.

Fix:The function reference is the contract: anything not listed there is intentionally out of scope in this zero-dependency build.

Mistake:Chaining a path directly after a function call.

Fix:Wrap the function in $map instead: $map($sort(scores, score), name).

Mistake:Treating bindings as expression text.

Fix:Bindings must be a JSON object in the bindings pane; keys become $name variables.

Mistake:Reading a null result as an empty object.

Fix:null plus the no-match chip means the expression produced JSONata undefined for this input.

Mistake:Pasting invalid JSON and assuming the expression changed.

Fix:The sample pane reports the parse error separately and the expression editor is left untouched.

Frequently asked questions

Is this the full JSONata language?

No. It is a deliberately small, zero-dependency subset covering paths, dot navigation, wildcards, indexes, flattening, simple predicates, JSON bindings and the functions listed in the reference panel. Object constructors, regex functions, recursion and sort evaluators are out of scope; the panel shows exactly what runs here.

How do bindings work?

Enter a JSON object such as {"wanted": "admin"} in the bindings editor and reference its keys as $wanted in the expression. Bindings are parsed as JSON and passed through a variable table — they are never concatenated into the expression text.

Why can't I write $sort(scores, score).name?

Chaining a path after a function call is not part of this subset. Use $map($sort(scores, score), name) instead: $map evaluates its second argument with each sorted item as the context.

What does a null result mean?

JSONata's undefined result is displayed as null with a no-match chip. It means the expression evaluated successfully but found no value for this sample document; it is not an error and not an empty object.

How are errors reported?

Syntax and runtime errors show a JSONata-style code such as T2002 for a missing bracket or D3001 for an unknown function, together with the line and column in the expression. The sample pane reports invalid JSON separately and leaves your expression untouched.

Is my JSON uploaded or executed on a server?

No. Evaluation happens in the browser tab with no external engine, no network request and no eval/Function call. Samples, expressions and bindings never leave the page.

References & standards