Skip to main content

Menu

LEVEL 0
0/5 XP
HomeAboutTopicsPricingMy VaultStatsPractice TestsCertifications

Categories

πŸŽ“ Certifications
πŸ€– Artificial Intelligence
☁️ Cloud and Infrastructure
πŸ’Ύ Data and Databases
πŸ’Ό Professional Skills
🎯 Programming and Development
πŸ”’ Security and Networking
πŸ“š Specialized Topics
CheatGrid
HomeAboutTopicsPricingMy VaultStatsPractice TestsCertifications
LVLEVEL 0
0/5 XP
GitHub
Β© 2026 CheatGridβ„’. All rights reserved.
Privacy PolicyTerms of UseAboutContact

jq Command-Line JSON Processor Cheat Sheet

jq Command-Line JSON Processor Cheat Sheet

Back to Operating Systems and CLI
Updated 2026-05-21
Next Topic: Linux Bash Cheat Sheet

jq is a lightweight, flexible command-line JSON processor written in portable C with zero runtime dependencies. Every jq program is a filter β€” it takes a JSON input and produces one or more JSON outputs. Filters are composed with | (pipe) and , (multiple outputs). jq is available on Linux, macOS, and Windows and is a staple of shell scripting for working with APIs, Kubernetes, Docker, AWS CLI, and any JSON data stream.


What This Cheat Sheet Covers

This topic spans 15 focused tables and 200 indexed concepts. Below is a complete table-by-table outline of this topic, spanning foundational concepts through advanced details.

Table 1 β€” Invocation Flags and Basic SyntaxTable 2 β€” Field Selection and Object ConstructionTable 3 β€” Array Indexing, Slicing, and IterationTable 4 β€” Aggregation and SortingTable 5 β€” String Functions and InterpolationTable 6 β€” Regular ExpressionsTable 7 β€” Variables, Arguments, and EnvironmentTable 8 β€” Format Strings and Output FormattersTable 9 β€” Paths and Update OperatorsTable 10 β€” Conditionals, Comparisons, and Boolean LogicTable 11 β€” Recursive Descent and Advanced TraversalTable 12 β€” Custom Functions and ModulesTable 13 β€” Math and Date FunctionsTable 14 β€” Real-World Pipelines and Tool IntegrationTable 15 β€” Shell Quoting, Common Pitfalls, and Tool Comparisons

Table 1 β€” Invocation Flags and Basic Syntax

Before you write any filter, these are the command-line knobs that shape how jq reads input and prints output. The ones you'll use constantly are -r for raw (unquoted) strings, -c for compact one-line output, and -n/-s for controlling whether jq reads stdin at all or slurps it into a single array. The identity filter . and the | and , operators at the bottom are the two building blocks every larger filter is composed from.

Flag / SyntaxExampleDescription
Identity filter .
echo '{"a":1}' | jq '.'
β€’ Pass input through unchanged
β€’ pretty-prints by default
-c compact
jq -c '.'
Compact (minified) output β€” no whitespace
-r raw output
jq -r '.name'
Print strings without JSON quotes
-j join
jq -j '.a, .b'
Like -r but no trailing newline between outputs
-n null-input
jq -n '{"x":1}'
β€’ Don't read stdin
β€’ useful for constructing JSON from scratch
-s slurp
jq -s '.[0]'
Read all inputs into one array before filtering
-R raw-input
jq -R '.'
Read each line as a raw string (not JSON)
-e exit-status
jq -e '.ok'
Exit 1 if last output is false or null

More in Operating Systems and CLI

  • journalctl and systemd Logging Cheat Sheet
  • Linux Bash Cheat Sheet
  • AWS CLI Cheat Sheet
  • iptables Legacy Linux Firewall Reference Cheat Sheet
  • nftables Modern Linux Firewall Cheat Sheet
  • tar gzip zip Archive and Compression Tools Cheat Sheet
View all 51 topics in Operating Systems and CLI