Try jq filters on your JSON and see the output as you type. This is the real jq, compiled to WebAssembly, running in your browser. For inputs over 20 MB, use the JSONPath Tester or the JMESPath Playground.
How to use it
- Start from the bookstore example, or paste your own JSON with Edit or Open file.
- Pick an "I want to" pattern, click a line of the data to put its path in the filter, or type: suggestions come from the data.
- Read the output as JSON, a table or text. Explain shows each stage of the pipeline, and a hint offers a fix when a filter fails or finds nothing.
- Copy for… gives the filter as a jq command, or Python or JavaScript code.
Read more: Compare two JSON files: values, key order and saved history · How to view and query API responses and NDJSON logs · jq vs JSONPath vs JMESPath: the same 8 tasks in all three
Private, and made for big files
This tool runs in your browser, in a background worker: nothing you paste or open is uploaded, and nothing is kept after you leave. JSONPath and JMESPath work on files of hundreds of megabytes; jq on inputs up to about 20 MB. Already loaded features keep working if your connection drops. Loading another tool or jq for the first time needs a connection. When one tool isn't enough, GigaJSON opens your data with a tree, a table, JSONPath/JMESPath/jq queries, transforms, diff and history.
Filter records and return only the IDs
Use the three-order input shown below:
{"orders":[{"id":"ord_001","status":"paid","total":89},{"id":"ord_002","status":"pending","total":149},{"id":"ord_003","status":"pending","total":29}]}Run:
[.orders[] | select(.status == "pending" and .total > 100) | .id]The result is ["ord_002"]. The brackets collect the emitted IDs into an array. .orders | length returns 3; [.orders[].total] | add returns 267.
jq loads when this page needs it. Keep jq input under its 20 MB limit. For larger files, try the JSONPath tester or JMESPath playground. Our query comparison runs the same tasks in all three languages.


jq syntax, with examples
Each example runs on the bookstore data in the playground with jq 1.8, the jq this page runs, and shows its real output. When a filter gives several outputs, each is on its own line, as jq prints them. Try it loads the example above.
. The whole input
.store.name"Corner Books".a.b A field inside a field
.store.books[0].title"Sayings of the Century".[0] .[-1] One item by position. -1 is the last
.store.books[-1].title"The Lord of the Rings".[1:3] A slice of a list
.store.books[1:3] map(.title)[
"Sword of Honour",
"Moby Dick"
].[] Every item, one output each
.store.books[].title"Sayings of the Century"
"Sword of Honour"
"Moby Dick"
"The Lord of the Rings"| Pass each output to the next filter
.store.books[] .author"Nigel Rees"
"Evelyn Waugh"
"Herman Melville"
"J. R. R. Tolkien"select( ) Keep the values where the condition is true
.store.books[] select(.price 10) .title"Sayings of the Century"
"Moby Dick"and or not Combine conditions
.store.books[] select(.price 10 and (.tags index("fiction"))) .title"Moby Dick"{ } Build an object. {title} is short for {title: .title}
.store.books[] {title, price}{"title":"Sayings of the Century","price":8.95}
{"title":"Sword of Honour","price":12.99}
{"title":"Moby Dick","price":8.99}
{"title":"The Lord of the Rings","price":22.99}[ ] Collect every output into one list
[.store.books[].price][
8.95,
12.99,
8.99,
22.99
]// A default when the value is null or missing
.store.books[0] .isbn "none""none""\( )" Put values into text
.store.books[0] "\(.title) costs \(.price)""Sayings of the Century costs 8.95"as $name Keep a value for later
.store.name as $shop .store.books[0] "\(.title) at \($shop)""Sayings of the Century at Corner Books"jq functions
jq has hundreds of built-in functions. These are the ones most filters use. Functions that run on each item take it as . inside their parentheses.
length How many items, keys or characters
.store.books length4keys The keys of an object, sorted
.store.books[0] keys[
"author",
"price",
"tags",
"title"
]map( ) Apply a filter to each item of a list
.store.books map(.title)[
"Sayings of the Century",
"Sword of Honour",
"Moby Dick",
"The Lord of the Rings"
]sort_by( ) Sort a list by a value
.store.books sort_by(.price) map(.title)[
"Sayings of the Century",
"Moby Dick",
"Sword of Honour",
"The Lord of the Rings"
]group_by( ) Group the items that share a value
.store.books group_by(.tags[0]) map({tag: .[0].tags[0], count: length})[{"tag":"fantasy","count":1},{"tag":"fiction","count":2},{"tag":"quotes","count":1}]unique Sort and drop duplicates
[.store.books[].tags[]] unique[
"classic",
"fantasy",
"fiction",
"quotes",
"war"
]add Add up numbers, or join lists and strings
.store.books map(.price) add53.92max_by( ) min_by( ) The item with the largest or smallest value
.store.books max_by(.price) .title"The Lord of the Rings"test( ) A string matches a regular expression
.store.books[] select(.title test("^S")) .title"Sayings of the Century"
"Sword of Honour"split( ) join( ) Split text into a list, or join a list into text
[.store.books[].author] join(", ")"Nigel Rees, Evelyn Waugh, Herman Melville, J. R. R. Tolkien"to_entries An object as a list of {key, value}
.store.books[0] to_entries map(.key)[
"title",
"author",
"price",
"tags"
]has( ) An object has a key
.store.books[] has("isbn")false
false
false
falsejq command-line recipes
Each recipe is a full jq command for bash or zsh, with its output on the example data in data.json. -r prints strings without quotes, and -c prints each output on one line.
Pretty-print a file
jq '.store.books[0]' data.json{
"title": "Sayings of the Century",
"author": "Nigel Rees",
"price": 8.95,
"tags": [
"quotes"
]
}jq . data.json prints the whole file indented and coloured.
Pick a few fields from each record
jq -c '.store.books[] | {title, price}' data.json{"title":"Sayings of the Century","price":8.95}
{"title":"Sword of Honour","price":12.99}
{"title":"Moby Dick","price":8.99}
{"title":"The Lord of the Rings","price":22.99}Filter records by a value
jq '[.store.books[] | select(.price < 10) | .title]' data.json[
"Sayings of the Century",
"Moby Dick"
]Count the items
jq '.store.books | length' data.json4Add up a field
jq '.store.books | map(.price) | add' data.json53.92Sort by a field
jq '.store.books | sort_by(.price) | map(.title)' data.json[
"Sayings of the Century",
"Moby Dick",
"Sword of Honour",
"The Lord of the Rings"
]Group and count
jq '.store.books | group_by(.tags[0]) | map({tag: .[0].tags[0], count: length})' data.json[{"tag":"fantasy","count":1},{"tag":"fiction","count":2},{"tag":"quotes","count":1}]CSV for a spreadsheet
jq -r '.store.books[] | [.title, .price] | @csv' data.json"Sayings of the Century",8.95
"Sword of Honour",12.99
"Moby Dick",8.99
"The Lord of the Rings",22.99@csv quotes each field as CSV needs; -r prints the lines as they are. Redirect to a file with > books.csv.
A line of text per record
jq -r '.store.books[] | "\(.title): \(.price)"' data.jsonSayings of the Century: 8.95
Sword of Honour: 12.99
Moby Dick: 8.99
The Lord of the Rings: 22.99Every distinct tag
jq '[.store.books[].tags[]] | unique' data.json[
"classic",
"fantasy",
"fiction",
"quotes",
"war"
]IDs of running EC2 instances, one per line
jq -r '.Reservations[].Instances[] | select(.State.Name == "running") | .InstanceId' data.jsoni-0f3a9c2e7b1d45e01
i-0b5e2f7a9c3d18e03Pipe aws ec2 describe-instances into it, or use the AWS CLI's own --query (see the JMESPath Playground).
Common jq errors and how to fix them
The messages come from jq 1.8, the jq this page runs; the jq command prints the same ones. The playground spots many of these mistakes as you type and offers the fix.
jq: error: Cannot index array with string ("price")
books is a list, and a list has no price field. [] takes each item in turn, so .price is read from each book.
.store.books select(.price 10) .title.store.books[] select(.price 10) .title- This playground
jq: error (at /dev/stdin:0): Cannot index array with string ("price")
jq: error: syntax error, unexpected INVALID_CHARACTER
jq strings use double quotes. A single quote is not a character jq reads; in a shell, the whole filter goes in single quotes instead.
.store.books[] select(.author 'Herman Melville') .title.store.books[] select(.author "Herman Melville") .title- This playground
jq: error: syntax error, unexpected INVALID_CHARACTER
jq: error: store/0 is not defined
Paths start with a dot. Without it, jq looks for a function called store.
store.books.store.books- This playground
jq: error: store/0 is not defined
jq: error: lenght/0 is not defined
A misspelt function looks like an unknown one to jq. The /0 is the number of arguments it was called with.
.store.books lenght.store.books length- This playground
jq: error: lenght/0 is not defined
jq: error: syntax error, unexpected end of file
A parenthesis is never closed, so jq reaches the end of the filter while still expecting ).
.store.books[] select(.price 10 .title.store.books[] select(.price 10) .title- This playground
jq: error: syntax error, unexpected end of file, expecting ';' or ')'
jq: error: Cannot iterate over null (null)
Field names are case-sensitive. .store.Books is null, and [] can't take the items of null.
.store.Books[].title.store.books[].title- This playground
jq: error (at /dev/stdin:0): Cannot iterate over null (null)
Every item comes back from select( = )
A single = in jq sets a value: it changes each item's price to 8.99, which counts as true, so select keeps everything. Compare with ==.
[.store.books[] select(.price = 8.99)][.store.books[] select(.price 8.99)]- This playground
No error. The result is [{"title":"Sayings of the Century","author":"Nigel Rees","price":8.95,"tags":["quotes"]},…
Quoting a filter on Windows
In bash and zsh, put the filter in single quotes so the shell leaves it alone. In the Windows command prompt, single quotes don't work; the simplest fix is to save the filter in a file and run jq -f filter.jq data.json.
Questions
Is this the real jq?
Yes. It's jq compiled to WebAssembly (jq-wasm), so filters behave the way they do on the command line.
How large can the input be?
Up to about 20 MB for jq in the browser. For bigger documents, use JSONPath or JMESPath; they work on hundreds of megabytes.
Which jq version is it?
jq 1.8.2, through jq-wasm 3.0.0.
How do I select objects by a field value?
Use select: .orders[] | select(.total > 100) | .id returns the ID of each order over 100. Wrap the whole filter in [ ] to get one list instead of separate results.
How do I print strings without quotes?
Run jq with -r (raw output): jq -r '.orders[].id' data.json prints each ID on its own line, without quotes.
How do I turn JSON into CSV with jq?
Build a list per record and pass it to @csv, with -r: jq -r '.orders[] | [.id, .total] | @csv' data.json. @csv quotes each field as CSV needs.
Is my data uploaded?
No. The tool runs in your browser, in a background worker. Nothing you paste or open goes to a server, and nothing is kept after you leave the page.
All tools
- JSON FormatterIndent with 2 or 4 spaces, sort keys
- JSON ValidatorLine and column of the first error
- JSON MinifierRemove whitespace, see the bytes saved
- JSON RepairFixes quotes, commas, comments, AI output
- JSON Schema GeneratorA JSON Schema from examples
- JSON Schema ValidatorCheck JSON against a schema
- JSON Token CounterCount tokens, select data, compare JSON and TOON
- JSON EditorTree and code editing, undo and history
- Large JSON ViewerTree, table and search for huge files
- JSON Lines ViewerJSONL and NDJSON logs as a table
- JSON Log ViewerCount and filter JSON Lines logs
- Large CSV ViewerCSV files too big for Excel, up to 1 GB
- JSON VisualizerThe data as a graph, PNG and SVG export
- JSON DiffChanges between two documents
- JSON Path FinderClick a value, copy its path
- JSONPath TesterJSONPath, JMESPath and jq, live
- JMESPath PlaygroundJMESPath, for AWS CLI queries too
- jq PlaygroundReal jq in your browser
- JSON to CSVNested objects become dotted columns
- JSON to ExcelAn .xlsx sheet, numbers kept as numbers
- CSV to JSONDelimiters detected, 007 stays 007
- JSON to XML@keys become attributes
- XML to JSONRSS feeds, sitemaps, SOAP responses
- JSON to YAMLReadable YAML, ambiguous strings quoted
- YAML to JSONAnchors and multiple documents
- JSON Lines to JSONNDJSON or JSONL into one array
- JSON to JSON LinesA JSON array as one record per line
- JSON to TOONConvert JSON to TOON, with token counts
- JSON to MermaidA flowchart or class diagram, drawn
- JSON SplitterCut a big file into parts, or sample it
- JSON to TypeScriptInterfaces inferred from your data
- JSON to GoGo structs with json tags
- JSON to RustRust structs that derive serde's Serialize and Deserialize
- JSON to PythonPython dataclasses with type hints
- JSON to JavaJava classes with getters and setters
- JSON to C#C# classes with System.Text.Json attributes
- JSON to KotlinKotlin data classes
- JSON to SwiftSwift structs that conform to Codable, with CodingKeys
- JSON to DartDart classes with fromJson and toJson
- JSON to ZodZod schemas with TypeScript types inferred from them
- JWT DecoderHeader, payload and expiry, locally
- JSON EscapeText to a JSON string and back
- Sample JSON FilesDownload test JSON, 100 KB to 1 GB
- Sample JSON Lines FilesDownload test NDJSON, one record per line
- Sample CSV FilesDownload test CSV, 100 KB to 1 GB
- Sample XML FilesDownload test XML, 100 KB to 1 GB
- Sample GeoJSON FilesPoints, lines and polygons, up to 1 GB
- Sample Nested JSONRecords 8 levels deep, up to 1 GB
- Sample Unicode JSON13 scripts, emoji and escapes
- Sample API ResponsesJSON:API, HAL, GraphQL, pages, errors
- Large JSON File GeneratorTest data from 100 KB to 1 GB