jq Online Playground

Run jq filters directly in your browser — no install, no uploads. Paste JSON, type a filter, and get instant output.

100% client-side No uploads Free forever
jq filter:

JSON input

Output

jq Filter Reference

The most commonly used jq expressions, with examples you can click to load directly into the playground.

Identity & Field Access

FilterDescriptionExample output
.Identity — returns the input unchangedThe full input
.keyExtract a field from an object.name → "Alice"
.key.nestedAccess nested fields.user.address.city
.["key"]Access fields with special characters.["first-name"]
.key?Extract field, return null if missing (no error).missing? → null

Arrays

FilterDescriptionExample
.[]Iterate all elements of an array or objectStreams each element
.[0]Get element by index (negative counts from end).[-1] → last item
.[2:5]Slice from index 2 to 4Returns 3 elements
lengthNumber of elements in array, characters in string[1,2,3] | length → 3
firstFirst element of an arraySame as .[0]
lastLast element of an arraySame as .[-1]
reverseReverse the order of an array[3,1,2] | reverse → [2,1,3]
uniqueRemove duplicate values[1,2,1] | unique → [1,2]
flattenFlatten nested arrays[[1,[2]],3] | flatten → [1,2,3]
min / maxMinimum or maximum value in an array[3,1,2] | max → 3
min_by(.f) / max_by(.f)Min/max by a fieldmin_by(.age)
addSum numbers, concatenate strings or arrays[1,2,3] | add → 6
indices("x")All indices where value appears"abab" | indices("a") → [0,2]

Transformation

FilterDescriptionExample
map(f)Apply filter to each element, return arraymap(.name) → ["Alice","Bob"]
map_values(f)Apply filter to each value in objectmap_values(. * 2)
select(cond)Keep elements where condition is true.[] | select(.age > 18)
sortSort a simple array[3,1,2] | sort → [1,2,3]
sort_by(.f)Sort array of objects by a fieldsort_by(.name)
group_by(.f)Group elements by a field valuegroup_by(.role)
unique_by(.f)Remove duplicates by fieldunique_by(.id)
to_entriesConvert object to [{key, value}] array{"a":1} | to_entries
from_entriesConvert [{key, value}] back to objectInverse of to_entries
with_entries(f)to_entries | map(f) | from_entriesTransform key/value pairs
keysGet array of object keys, sorted{"b":2,"a":1} | keys → ["a","b"]
valuesGet array of object values{"a":1} | values → [1]
has("key")Test if object has a keyhas("name") → true/false
in(obj)Test if value is a key in obj"name" | in({"name":1})
contains(x)Test if input contains x[1,2,3] | contains([2])

Pipes & Composition

FilterDescriptionExample
f | gPipe output of f into g.users | map(.name)
f, gProduce outputs from both f and g.a, .b
[f]Collect all outputs of f into an array[.[] | .name]
{a: .x, b: .y}Construct a new object{name: .name, age: .age}
emptyProduce no output (useful with select)Filters out values
notBoolean negationselect(.active | not)
typeGet the type of a value"hello" | type → "string"
tostringConvert value to a JSON string42 | tostring → "42"
tonumberConvert string to number"42" | tonumber → 42
ascii_downcaseLowercase a string"HELLO" | ascii_downcase
ascii_upcaseUppercase a string"hello" | ascii_upcase
ltrimstr("x") / rtrimstr("x")Remove prefix / suffix from string"foobar" | ltrimstr("foo") → "bar"
split("x") / join("x")Split string / join array into string"a,b" | split(",") → ["a","b"]
test("regex")Test if string matches regex"foo" | test("f.*") → true

Common jq Recipes

Extract a field from every object in an array

Given a JSON array of users, get all names:

[.[] | .name]
# or equivalently:
map(.name)

Filter an array by condition

Keep only active admins:

.[] | select(.active == true and .role == "admin")

Reshape objects

Create a new object with only the fields you need:

map({ id: .id, fullName: .name, isAdmin: (.role == "admin") })

Sort and deduplicate

# Sort by age, oldest first
sort_by(.age) | reverse

# Remove duplicates by email
unique_by(.email)

Group and count

# Group users by role, count each group
group_by(.role) | map({ role: .[0].role, count: length })

Extract nested values safely

# Returns null instead of error if path is missing
.user?.address?.city?

Frequently Asked Questions

What is jq?

jq is a lightweight command-line tool for processing JSON. It lets you extract fields, filter arrays, transform objects, and reshape data with a concise filter syntax. This playground runs jq-compatible filters directly in your browser — no install needed.

How do I extract a field with jq?

Use .fieldName to extract a top-level field. For example, .name returns the value of the name key. For nested fields, chain with dots: .user.address.city. For arrays, use .[] to iterate all elements or .[0] to get the first.

How do I filter an array with jq?

Use select() inside a pipe: .[] | select(.age > 18) returns only elements where age is greater than 18. You can combine conditions: .[] | select(.active == true and .role == "admin").

How do I sort a JSON array with jq?

Use sort to sort a simple array, or sort_by(.field) to sort an array of objects by a specific property. Add | reverse to flip the order. Example: sort_by(.age) | reverse sorts oldest-first.

Does this jq playground support all jq features?

It supports the most common operations: field access, array iteration, pipes, map(), select(), sort_by(), group_by(), keys, values, length, unique, reverse, first, last, min, max, and more. Advanced features like @base64, try-catch, and recursive descent (..) are not supported. For full jq, use the official jq tool.

Is my JSON data uploaded anywhere?

No. All jq filtering runs locally in your browser using JavaScript. Your JSON never leaves your device.

Need to lint or fix your JSON first?

If your JSON has syntax errors — trailing commas, single quotes, comments, missing brackets — use the JSON Linter and Fixer to repair it before filtering.