Home › Developer Tools › jq Playground

jq Playground

Type a jq filter and see the result instantly. Paste your JSON (or JSON Lines), toggle jq flags like -r, -c and -s, and learn from a library of ready-made filters. Everything runs locally in your browser.

Last updated:

Runs live as you type. Ctrl+Enter runs now. Multi-line filters, def functions and comments (#) are fine.

Input JSON
0 B
Output ready

      
    
Command line

Example filter library

Advertisement
Advertisement

How to use the jq Playground

  1. Paste your JSON into the Input box, drop a .json file on it, or keep the sample data.
  2. Type a jq filter such as .users[] | select(.active) | .name. The output updates as you type.
  3. Toggle flags like -r for raw strings, -c for one line per result or -s to slurp JSON Lines into an array.
  4. Browse the example library and click any card to load a working filter you can adapt.
  5. Copy or download the output, or copy the matching jq command to run in your terminal.

jq cheat sheet

FilterWhat it doesExample result
.Identity: the whole inputPretty-printed JSON
.key, .a.b, ."my-key"Object field (null if missing).name → "Ada"
.[0], .[-1], .[2:4]Array index, from the end, slice[1,2,3] | .[-1] → 3
.[], .[]?Every element / value (? ignores errors)One result per element
a | bPipe: feed each output of a into b.users[] | .name
a, bBoth outputs.name, .age
[ ... ], {a, b: .c}Build an array or object{name, city: .address.city}
select(cond)Keep the input only if cond is trueselect(.age > 30)
map(f), map_values(f)Apply f to every elementmap(.price * 2)
a // bAlternative: b when a is null, false or empty.email // "none"
.a = v, .a |= f, .a += 1Set, update or modify a path.n |= . + 1
del(.a), to_entries, with_entries(f)Delete paths, work with key/value pairswith_entries(.key |= ascii_upcase)
sort_by(f), group_by(f), unique_by(f)Sort, group or de-duplicate by a keysort_by(-.age)
add, length, min_by(f), max_by(f)Aggregate an array[.[].n] | add
reduce .[] as $x (init; update)Fold many values into onereduce .[] as $x (0; . + $x)
"\(.a) and \(.b)"String interpolation"Hi \(.name)"
test(), capture(), sub(), gsub()Regular expressionsgsub("\\s+"; " ")
@csv, @tsv, @base64, @uri, @html, @shFormat strings (use with -r)[.id, .name] | @csv
.., paths, getpath(p)Walk every value / path[.. | numbers]
try f catch g, f?Handle errorstry tonumber catch 0

jq command-line flags

FlagMeaningTypical use
-rRaw output: strings without quotesLists of names, CSV/TSV rows, shell scripts
-cCompact output: one result per lineProducing JSON Lines, logs
-sSlurp: read all inputs into one arrayCounting or summing JSON Lines
-nNull input: start with nullGenerating JSON, reading with input/inputs
-RRaw input: each line is a stringParsing CSV or plain text with jq
-SSort object keys in outputStable diffs
-jJoin: raw output without newlinesBuilding one long string
--arg name v / --argjson name jsonDefine $namePassing shell values into a filter safely

Tips for writing jq filters

Build filters step by step. Start with ., add one pipe at a time and watch the output change. When a step returns many results, wrap it in [ ] to see them as one array.

Missing fields are null, not errors. .missing returns null, but .missing[] or .missing.x on a number fails. Use ?, // default or select() to guard optional data.

Quote filters in the shell. On Linux and macOS wrap the filter in single quotes: jq -r '.items[] | .name' data.json. The command shown under the output is already quoted for you.

Frequently asked questions

What is jq?

jq is a command-line JSON processor. A jq filter describes how to transform JSON: pick fields with .name, iterate arrays with .[], filter with select(), reshape with {} and [] and aggregate with functions like map, group_by, add and reduce. This playground lets you try filters without installing anything.

Is my JSON uploaded to a server?

No. The jq engine runs entirely in JavaScript inside your browser (in a background worker), so your data never leaves your device and the page keeps working offline once loaded.

Is it the same as real jq?

The engine follows jq 1.7 syntax and semantics, including paths, assignment operators, reduce, foreach, label/break, try/catch, destructuring, @formats and most built-in functions. Small differences: regular expressions use the browser's engine instead of Oniguruma, dates are handled in UTC, modules (import/include) are not available, $ENV is empty and numbers are 64-bit floats.

How do I get output without quotes?

Turn on -r (raw output). Strings are then printed as plain text, which is what you want for lists of names, @csv or @tsv rows and shell scripts. Numbers, arrays and objects are still printed as JSON.

How do I process JSON Lines (NDJSON) or several JSON documents?

Paste them one after another. jq runs the filter once per value. Turn on -s (slurp) to read all values into a single array first, for example to count or sum them with length or add.

Why do I get "Cannot iterate over null" or "Cannot index" errors?

The filter tried to use .[] or .key on a value of the wrong type, often because a field is missing (null) on some items. Add ? to ignore errors (.items[]?), use // to provide a default (.items // []) or filter first with select(.items != null).

How do I pass a value into a filter like --arg?

Open Variables and add a line such as country=US (a string, like --arg) or limit:=10 (JSON, like --argjson). Use it in the filter as $country or $limit. The command line shown below the output includes the matching --arg options.

Are all the tools on FreeToolCabin tested for quality and accuracy?

Yes! Every tool on our site undergoes automated Q/A testing in real browser environments to ensure high precision, correct output, and zero errors. If you happen to spot a bug or have a suggestion, please contact us at [email protected] and our team will review it right away.

Related tools

JSONPath TesterTest JSONPath expressions live: filters, slices, wildcards and recursive search, with matches highlighted.JSON FormatterBeautify, minify and validate JSON, with a collapsible tree view.JSON ViewerExplore JSON as a collapsible tree, search keys and values and copy any node's path.JSON to CSVConvert JSON data to CSV for spreadsheets.Online Python CompilerRun Python 3 in your browser with input(), numpy, pandas, charts and share links.JSON EditorEdit JSON in a tree and as code side by side: add, rename, drag, change types, undo and download.Unzip FilesOpen and extract ZIP files online.RAR & 7z ExtractorOpen RAR, 7z and other archives online and extract files.Regex TesterTest and debug regular expressions live.File Info ViewerCheck file size, type, date and MD5/SHA hashes.SQLite ViewerOpen .db and .sqlite files in your browser, browse tables and run SQL queries.DOCX ViewerOpen and read Word .docx files in your browser, then print or save them as HTML.EPUB ReaderOpen and read EPUB e-books in your browser with pages, a table of contents and font controls.What Is My BrowserSee your browser, version, OS, engine, screen and which web features it supports.Font ViewerPreview TTF, OTF, WOFF and WOFF2 fonts with sample text, waterfall, glyphs and metadata.Markdown EditorWrite Markdown with a toolbar, live split preview, autosave and .md or HTML export.Regex Cheat Sheet75+ ready-to-use regex patterns for emails, URLs, IPs and dates, each with a live test box.JavaScript Keycode FinderPress any key to see its JavaScript key, code, keyCode, which, location and modifiers.QR Code ScannerScan QR codes with your camera or from an image and safely read the link or text.RAID CalculatorUsable capacity, efficiency and fault tolerance for RAID 0, 1, 5, 6, 10, 50 and 60 arrays.Mermaid Diagram EditorWrite Mermaid code and see flowcharts, sequence, Gantt and ER diagrams live. Export SVG or PNG.Country Codes ListSearch ISO 3166 alpha-2, alpha-3 and numeric country codes with calling codes and TLDs.CSS Selector TesterTest CSS selectors on your HTML: highlighted matches, match count and specificity.Git Cheat SheetSearchable Git command reference by task, with copy buttons and an undo/rename/fix wizard.HAR File ViewerOpen a .har file to see a waterfall timeline, headers, bodies, timings and size totals.Markdown Cheat SheetInteractive Markdown syntax reference: edit every example and see the live rendered preview.Regex ExplainerPaste a regular expression and get a plain-English breakdown, railroad diagram and flag notes.XPath TesterTest XPath expressions on XML or HTML: highlighted matches, node paths, values and examples.EML File ViewerOpen .eml email files to read the message, headers and raw source and save attachments.Graphviz Online ViewerWrite Graphviz DOT code and render graphs live; switch layout engines, export SVG or PNG.JavaScript Online CompilerWrite and run JavaScript in your browser with a console, timing, error lines and share links.Jupyter Notebook ViewerOpen .ipynb files and read code, Markdown, math, tables, plots and errors without Python.LaTeX Table GeneratorEdit a table like a spreadsheet or paste from Excel and get LaTeX tabular or booktabs code.Log File ViewerOpen huge log files with level colors, regex and time filters, JSON pretty-print and tail -f.Logic Gate SimulatorBuild logic circuits with AND, OR, NOT, XOR gates and flip-flops; see live outputs and truth tables.MSG File ViewerOpen Outlook .msg emails in your browser: sender, recipients, body, headers and attachments.Online Code EditorVS Code-style editor in your browser: tabs, 50+ languages, find/replace, autosave.Online Hex EditorOpen any file as hex and ASCII, edit bytes, search, inspect values and save the result.EditorConfig GeneratorBuild an .editorconfig with indent, charset, line endings and trim rules per file pattern.Folder Compare ToolCompare two folders by file list, size and SHA-256 hash, then open a text diff of changed files.Glob Pattern TesterTest glob patterns like **/*.js, {a,b} and !exclusions against a list of file paths.JMESPath TesterEvaluate JMESPath expressions against JSON live, the query language used by the AWS CLI.MongoDB Query TesterTest MongoDB find filters, projections and aggregation pipelines on sample JSON documents.Semantic Version CalculatorBump, compare, sort and test SemVer versions against npm ^, ~ and x ranges.XSLT TesterRun an XSLT 1.0 stylesheet on XML in your browser and see the output as HTML, XML or text.ASCII Diagram EditorDraw boxes, arrows and text on a character grid and copy plain-text diagrams for code and READMEs.DBF File ViewerOpen dBase .dbf files and shapefile tables, search and sort records, export CSV or XLSX.MBOX File ViewerOpen .mbox mail archives: list and search messages, read them, save attachments, export EML.MDB File ViewerOpen Access .mdb and .accdb databases in your browser: list tables, view rows, export CSV.Shapefile ViewerView zipped shapefiles on a map with the attribute table, then export to GeoJSON or CSV.PHP Online CompilerRun PHP 8 code in your browser with output, HTML preview, error lines and share links.PlantUML EditorWrite PlantUML and see sequence, class, activity and more diagrams live. Export SVG or PNG.Sorting Algorithm VisualizerWatch bubble, insertion, merge, quick, heap and radix sort step by step with live counters.Lottie ViewerOpen Lottie JSON or .lottie files to play, pause, scrub frames, change speed and see details.Diff ViewerPaste a git diff or .patch file and view it side by side or inline, with file navigation.
See all 53 Code Playgrounds & Testers →