Skip to content
Skillpedia
Analysis & spreadsheets29k Β· #9767

jq

What it does

This skill helps you pull out, filter and reshape information from JSON data. It is for anyone working with API responses, config files or logs who needs one specific piece of data.

When to use it

  • βœ“When you need to pull one field or a filtered list out of a JSON response.
  • βœ“When you want to reshape JSON data into a different structure.
  • βœ“When you are reading a config file or log in JSON and need a quick answer.

Skill link

https://github.com/charmbracelet/crush/blob/main/internal/skills/builtin/jq/SKILL.md

Copy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.

How to use

The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.

Ready-to-paste message

Use this skill to help me: https://github.com/charmbracelet/crush/blob/main/internal/skills/builtin/jq/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
Want your AI to find skills like this on its own?Install the free Skillpedia MCP: one line, and it searches 15,000+ skills before each task.Install in 1 minute β†’

Example of what to ask your AI

β€œFrom this API response, give me just the names and email addresses of all active users as a list.”

5 new skills a week. 1 minute to read.

How it works

The agent writes a jq filter that selects, filters or rebuilds the JSON and returns the result. The built-in jq supports common flags such as raw output and compact output.

Technical content (original SKILL.md)

Original text by the author, straight from GitHub.

jq β€” Built-in JSON Processor

Crush ships a built-in jq command (via github.com/itchyny/gojq) available in the bash tool. No external binary is required.

Supported Flags

Flag Description
-r, --raw-output Output strings without quotes
-j, --join-output Like -r but no trailing newline
-c, --compact-output One-line JSON output
-s, --slurp Read all inputs into an array
-n, --null-input Use null as input (ignore stdin)
-e, --exit-status Exit 1 if last output is false or null
-R, --raw-input Read each line as a string, not JSON
--arg name value Bind $name to a string value
--argjson name value Bind $name to a parsed JSON value

File arguments after the filter are also supported: jq '.foo' file.json.

Differences from Standard jq

The built-in uses gojq, which is a pure-Go jq implementation. Key differences:

  • No object key ordering β€” keys are sorted by default; keys_unsorted and -S are unavailable.
  • Arbitrary-precision integers β€” large integers keep full precision (addition, subtraction, multiplication, modulo, division when divisible).
  • String indexing β€” "abcde"[2] returns "c".
  • Not supported β€” --ascii-output, --seq, --stream, --stream-errors, -f/--from-file, --slurpfile, --rawfile, --args, --jsonargs, input_line_number, $__loc__, some regex features (backreferences, look-around).
  • YAML β€” gojq supports --yaml-input/--yaml-output but the built-in does not currently expose these flags.

Common Patterns

Extract a field:

echo '{"name":"crush"}' | jq '.name'

Filter an array:

echo '[1,2,3,4,5]' | jq '[.[] | select(. > 3)]'

Reshape objects:

echo '{"first":"Ada","last":"Lovelace"}' | jq '{full: (.first + " " + .last)}'

Use variables:

echo '{}' | jq --arg host localhost --argjson port 8080 '{host: $host, port: $port}'

Slurp multiple JSON values:

echo '{"a":1}{"b":2}' | jq -s '.'

Compact output for piping:

echo '{"a":1}' | jq -c '.a += 1'

Raw string output:

echo '["one","two","three"]' | jq -r '.[]'

Process a file:

jq '.dependencies | keys' package.json

Null input for constructing JSON:

jq -n --arg msg hello '{"message": $msg}'

Tips

  • Pipe jq output to other commands: jq -r '.url' data.json | xargs curl
  • Chain filters with | inside the expression, not shell pipes.
  • Use try to suppress errors on missing keys: jq 'try .foo.bar'
  • Use // "default" for fallback values: jq '.name // "unknown"'
  • Use @csv, @tsv, @base64, @html, @uri for format strings.
FAQ

Do I need to install jq separately?

No. The jq command is built in and needs no external program.

Does it work exactly like standard jq?

Mostly, but object keys are sorted by default, and some standard flags are not available.

Can it read files as well as piped data?

Yes. You can pass a file name after the filter.

Details

Original description by the author

Use when the user needs to query, filter, reshape, extract, create, or construct JSON data β€” including API responses, config files, log output, or any structured data β€” or when helping the user write or debug JSON transformations.

repo: charmbracelet/crush

Popularity

GitHub stars
29k
Ranking position
#9767
License
β€”
Updated
11/2/2026

Is this skill useful?

0

Sign in to vote.

Comments

  • …

More skills from this repository

Similar skills