jq Playground

Query and transform JSON data with jq-like expressions. Filter, map, and transform your data interactively.

Input JSON
Drop JSON file here
Input JSON

Supported Operations

⚡ Basic Operations

  • . - Identity
  • .foo - Property access
  • .foo.bar - Nested access
  • .[] - Iterate array
  • .[0] - Index access

🔧 Functions

  • length - Array/string length
  • keys - Object keys
  • values - Object values
  • map(expr) - Transform each
  • select(cond) - Filter

đŸ“Ļ Construction

  • {a, b} - Object from fields
  • [.foo, .bar] - Array
  • | pipe - Pipe operations
  • first - First element
  • last - Last element

jq Playground Guide

jq is the standard command-line tool for slicing, filtering, and transforming JSON — used everywhere from shell pipelines (curl ... | jq '.data[]') to CI scripts. This playground implements a practical subset of jq syntax entirely in your browser, so you can prototype an expression against real data before dropping it into a script, without installing anything or piping data through a terminal.

Start simple: . returns the whole document, .users[0].name drills into a specific field, and .users | map(.name) pipes an array through a transformation. Combine select() with a condition to filter — for example .items[] | select(.price > 100) — and use {name, id} shorthand to reshape objects down to just the fields you need.

Frequently Asked Questions

Does this support every jq feature?

No — this covers the operations most people reach for daily (field/array access, map, select, length, keys/values, object/array construction, and pipes). Advanced jq features like custom function definitions, reduce, and regex builtins aren't implemented; for those, use the real jq CLI.

How do I filter an array of objects?

Pipe the array through select() with a comparison, e.g. .products[] | select(.inStock == true) — this evaluates the condition against every element and keeps only the ones that match.

What's the difference between jq, JSONPath, and JMESPath?

All three query JSON, but jq reads like a small pipeline language (great for chaining transforms), JSONPath uses a compact $.a.b[0] path syntax popular in JavaScript tooling, and JMESPath is the query language behind the AWS CLI's --query flag. Try all three in this site's playgrounds to see which reads more naturally for your use case.

Common jq recipes

jq is the standard command-line tool for slicing JSON in shells and CI scripts. A handful of patterns covers most daily needs, and this playground is a safe place to try them before putting them in a script.

Tips and common pitfalls

  • .items[] | {id, name} reshapes each item to just the fields you need.
  • map(select(.active)) keeps only matching elements while preserving the array.
  • [.[] | .price] | add sums a field across all elements.
  • On the command line, jq -r prints raw strings without quotes, which is ideal for passing values to other commands.

More questions

How do I use jq with curl?

Pipe the response into it: curl -s https://api.example.com/users | jq ".[0].name".

Why does my filter return several outputs instead of an array?

The .[] operator emits each element separately. Wrap the expression in square brackets, [ ... ], to collect the results into one array.