Skip to content
Search

Jq

lastmod 2026-06-10created 2020-12-0415 edits

jq is a lightweight and flexible command-line JSON processor.

About

jq is like sed for JSON data.

  • That is, just as tools like sed, awk, and grep handle text, jq lets you easily slice, filter, map, and transform structured data.
  • jq is written in portable C and has no runtime dependencies. You can download a single binary, scp it to a remote machine of the same type, and it works right away.
  • jq can convert your current data format into the format you want with minimal effort, and the programs to do so are often short and concise.

Example

  • .info.datas[0].meta

How to add an Object

cat fruits.json | jq '. += {"vegetable" : { "name" : "brinjal" }}'

Using a key's value as a key

echo '{"name": "merry", "friends": ["mia","ava"]}' | jq -c '{(.name): .friends}'

Result:

{"merry":["mia","ava"]}

How to remove quoting from strings

echo '{"job_id": "1234"}' | jq '.job_id'

The result is "1234", printed with quotes. To remove the quotes, add the -r (Raw Output) option:

echo '{"job_id": "1234"}' | jq -r '.job_id'

The result is printed as 1234.

How to merge results into strings

[
  {"key": "name", "value": "John"},
  {"key": "age", "value": 30},
  {"key": "city", "value": "New York"}
]
cat data.json | jq -r '.[] | "\(.key)=\(.value)"'

Result:

name=John
age=30
city=New York

See also

  • Json
  • htmlq - Like jq, but for HTML.
  • Fq - jq for binary formats
  • pyjq - A Python binding for ./jq
  • jqpy - Python bindings for jq
  • jq.py - JQpy is Python binding for JQ (JSON processing language) that simply works on any platform (even Windows) and does not require compilation.
  • jmespath
  • jsonpath-ng
  • jsonschema
  • mdq - jq for Markdown
  • JSON Query - A small, flexible, and extensible JSON query language
  • jsongrep - Faster than jq
  • mq - jq-style Markdown query language

Favorite site

Online Tools

author Zer0 sitemap