Skip to main content

Menu

LEVEL 0
0/5 XP
HomeAboutTopicsPricingMy VaultStats

Categories

πŸ€– Artificial Intelligence
☁️ Cloud and Infrastructure
πŸ’Ύ Data and Databases
πŸ’Ό Professional Skills
🎯 Programming and Development
πŸ”’ Security and Networking
πŸ“š Specialized Topics
HomeAboutTopicsPricingMy VaultStats
LEVEL 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

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
  • GCP CLI Cheat Sheet
  • macOS Usage Cheat Sheet
  • systemd and Linux Service Management Cheat Sheet
View all 48 topics in Operating Systems and CLI