jq Playground
Query and transform JSON with jq expressions
Supported: .field, .[], .[0], .[0:5], keys, values, length, type, sort, sort_by(.f), reverse, unique, flatten, first, last, add, min, max, select(.f > N), map(.f), group_by(.f), to_entries, from_entries, { f1, f2 }, pipe |
Frequently Asked Questions
What is jq?
+
jq is a lightweight, command-line JSON processor. It lets you slice, filter, map, and transform JSON data using a concise expression language. jq is widely used in shell scripting to extract specific fields from API responses, reformat data, and perform calculations on JSON arrays — similar to how sed and awk work for text.
What does the dot (.) expression do in jq?
+
The dot (.) is the identity operator — it outputs the input unchanged. It is also used as a prefix for field access: .name extracts the 'name' field from an object, .address.city chains through nested fields, and .[] iterates over every element in an array or every value in an object.
How do I filter an array to only matching items?
+
Use the select() function with a condition. For example, .[] | select(.age > 18) iterates over every element and keeps only those where the 'age' field is greater than 18. You can chain multiple conditions with and/or and use comparison operators ==, !=, <, >, <=, >=.
What does the pipe operator (|) do?
+
The pipe operator passes the output of one expression as the input to the next, similar to Unix shell pipes. For example, .users | .[] | .email first extracts the 'users' array, then iterates over each element, then extracts the 'email' field from each — producing a list of all email addresses.
What are the limitations of this browser-based jq tool?
+
This tool implements a subset of jq in JavaScript to run entirely in your browser without any server. It supports the most common operations: field access, array iteration, slicing, pipes, map, select, sort_by, group_by, keys, length, type, unique, flatten, add, min, max, to_entries, from_entries, and object construction. Advanced features like try-catch, label-break, SQL-style operators, streaming, and user-defined functions are not implemented.