jq . file.json

is what I was looking for. I didn't realize that the . is a filter and not a placeholder for the piped in content:

.

The absolute simplest (and least interesting) filter is .. This is a filter that takes its input and produces it unchanged as output.

And the man page makes it clear that the filter is a required argument.

Answer from k0pernikus on Stack Exchange
Top answer
1 of 10
208

Using the @tsv filter has much to recommend it, mainly because it handles numerous "edge cases" in a standard way:

.[] | [.id, .name] | @tsv

Adding the headers can be done like so:

jq -r '["ID","NAME"], ["--","------"], (.[] | [.id, .name]) | @tsv'

The result:

ID  NAME
--  ------
12  George
18  Jack
19  Joe

As pointed out by @Tobia, you might want to format the table for viewing by using column to post-process the result produced by jq. If you are using a bash-like shell then column -ts $'\t' should be quite portable.

length*"-"

To automate the production of the line of dashes:

jq -r '(["ID","NAME"] | (., map(length*"-"))), (.[] | [.id, .name]) | @tsv'
2 of 10
118

Why not something like:

echo '[{
    "name": "George",
    "id": 12,
    "email": "[email protected]"
}, {
    "name": "Jack",
    "id": 18,
    "email": "[email protected]"
}, {
    "name": "Joe",
    "id": 19,
    "email": "[email protected]"
}]' | jq -r '.[] | "\(.id)\t\(.name)"'

Output

12  George
18  Jack
19  Joe

Edit 1 : For fine grained formatting use tools like awk

 echo '[{
    "name": "George",
    "id": 12,
    "email": "[email protected]"
}, {
    "name": "Jack",
    "id": 18,
    "email": "[email protected]"
}, {
    "name": "Joe",
    "id": 19,
    "email": "[email protected]"
}]' | jq -r '.[] | [.id, .name] | @csv' | awk -v FS="," 'BEGIN{print "ID\tName";print "============"}{printf "%s\t%s%s",2,ORS}'
ID  Name
============
12  "George"
18  "Jack"
19  "Joe"

Edit 2 : In reply to

There's no way I can get a variable containing an array straight from jq?

Why not?

A bit involved example( in fact modified from yours ) where email is changed to an array demonstrates this

echo '[{
    "name": "George",
    "id": 20,
    "email": [ "[email protected]" , "[email protected]" ]
}, {
    "name": "Jack",
    "id": 18,
    "email": [ "[email protected]" , "[email protected]" ]
}, {
    "name": "Joe",
    "id": 19,
    "email": [ "[email protected]" ]
}]' | jq -r '.[] | .email'

Output

[
  "[email protected]",
  "[email protected]"
]
[
  "[email protected]",
  "[email protected]"
]
[
  "[email protected]"
]
Discussions

Create jqfmt to format jq scripts
I've written an appreciably long jq template that I'm rationally storing in a file in invoking with jq --from-file script.jq. Frustratingly, I had to format it myself by hand in order to un... More on github.com
🌐 github.com
5
November 4, 2021
Pretty printing in jq - Stack Overflow
If you want to control the newlines around the pretty-printed JSON (as you did with your jq -r '"…\n\(.)\n…"' approach), use the -j option with the stream approach: jq -j '"…\n", ., "\n…\n"'. This way, by omitting the according newlines, you can place text on the same line as the first ... More on stackoverflow.com
🌐 stackoverflow.com
jq - How to take string format from command line? - Stack Overflow
https://stedolan.github.io/jq/manual/#Stringinterpolation-\(foo) I want to pass string format from the command line of jq, instead of embedding the format in string interpolation. Let's say the ... More on stackoverflow.com
🌐 stackoverflow.com
optimization - jq: Format a JSON file with the output replacing the input file - Stack Overflow
I want to use jq to format a JSON file in Windows. So far, I haven't been able to find a way to perform this task using a single jq command. Thus, I wrote this batch file: rem create formatted JSON More on stackoverflow.com
🌐 stackoverflow.com
🌐
jq
jqlang.org
jq
jq can mangle the data format that you have into the one that you want with very little effort, and the program to do so is often shorter and simpler than you'd expect.
🌐
LornaJane
lornajane.net › posts › 2024 › pretty-print-json-with-jq
Pretty-print JSON with jq | LornaJane
Wrangling some document conversion the other day, I ended up in a situation where I had the JSON I needed, but in a completely unreadable format. Luckily, this problem is very easily fixable …. when you know how. So today’s post is a quick recap on how I did that using jq, a very handy command-line tool for working with JSON.
🌐
Programming Historian
programminghistorian.org › en › lessons › json-and-jq
Reshaping JSON with jq | Programming Historian
May 24, 2016 - To format this as CSV, add the operator @csv on the end with another pipe and check the “Raw Output” box in the upper right. @csv properly joins the arrays with , and adds quotes where needed. “Raw Output” tells jq that we want to produce a text file, rather than a new JSON file.
🌐
DigitalOcean
digitalocean.com › community › tutorials › how-to-transform-json-data-with-jq
How To Transform JSON Data with jq | DigitalOcean
September 23, 2025 - This textbox defaults to using Markdown to format your answer. You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link! ... Thanks for the article. If you want to use jq in JetBrains products (e.g.IntelliJ), there is a plugin for it: https://plugins.jetbrains.com/plugin/23360-jqexpress
Find elsewhere
🌐
Linode
linode.com › docs › guides › using-jq-to-process-json-on-the-command-line
How to Use JQ to Process JSON on the Command Line | Linode Docs
November 5, 2021 - This operation takes a JSON file and formats it into easy-to-read output, with proper line spacing, standard indentation, and perfectly aligned braces. To prettify a JSON file, use the jq '.' command.
🌐
GitHub
github.com › jqlang › jq › issues › 2366
Create jqfmt to format jq scripts · Issue #2366 · jqlang/jq
November 4, 2021 - I've written an appreciably long jq template that I'm rationally storing in a file in invoking with jq --from-file script.jq. Frustratingly, I had to format it myself by hand in order to un...
Author   colindean
🌐
Chris's Wiki
utcc.utoronto.ca › ~cks › space › blog › sysadmin › JqFormattingTextNotes
Some notes (to myself) about formatting text in jq
August 10, 2022 - First, I basically always want to use 'jq -r' so that strings aren't quoted (and strings may include what are actually numbers but rendered as strings by the tool). Then I know of several ways to produce text in a useful form. Often the simplest way is to put the values into a JSON array and run them through the '@tsv' filter (described in the "Format strings and escaping" section of the manual), which produces tab separated output:
🌐
jq
jqlang.org › manual
jq 1.8 Manual
By default, jq pretty-prints JSON output. Using this option will result in more compact output by instead putting each JSON object on a single line. ... With this option, if the filter's result is a string then it will be written directly to ...
🌐
Zendesk Developer Docs
developer.zendesk.com › documentation › integration-services › developer-guide › jq-cheat-sheet
jq cheat sheet | Zendesk Developer Docs
jq supports several date-related functions. The now function gets the current time in seconds since the Unix epoch. You can use the strftime function to format this timestamp.
🌐
Stack Overflow
stackoverflow.com › questions › 71458511 › how-to-take-string-format-from-command-line
jq - How to take string format from command line? - Stack Overflow
jq -r -e -n --arg f "my string %s" '$f | sub("%s"; input)' <<< '"x"' ... Sign up to request clarification or add additional context in comments. ... "my string %s" must be in --arg as in --arg format "my string %s". It can not be in a jq expression.
🌐
Baeldung
baeldung.com › home › web › guide to linux jq command for json processing
Guide to Linux jq Command for JSON Processing | Baeldung on Linux
August 31, 2025 - Then we use the identity filter ‘.’ that takes the input and produces it unchanged as output with the caveat that by default jq pretty-prints all output. ... Being able to prettify JSON is particularly useful when we want to retrieve data from an API and see the response in a clear, readable format.
🌐
DevDocs
devdocs.io › jq
DevDocs — jq documentation
jq 1.7 API documentation with instant search, offline support, keyboard shortcuts, mobile version, and more.
🌐
Benfalk
benfalk.com › blog › 2015 › 11 › 11 › formatting-json-with-jq
Formatting JSON With Jq - benfalk.com
November 11, 2015 - If you haven’t tried it out yet, I highly recommend checking out the application jq. It allows you to quickly format json with bash or any …
🌐
Baeldung
baeldung.com › home › files › file viewing › transform a json string into a table using jq
Transform a JSON String Into a Table Using jq | Baeldung on Linux
May 9, 2025 - The JavaScript Object Notation (JSON) format has been around as an IETF Information Standard since 2006. It’s widely used for the storage of structured data in the field of data analytics. In this tutorial, we’ll explore various ways to convert a JSON dataset to a table using jq.
🌐
Shapeshed
shapeshed.com › jq-json
JSON on the command line with jq | George Ornbo
September 19, 2024 - jq - JSON formatting tool · jq is a fantastic command-line JSON processor. It plays nice with UNIX pipes and offers extensive functionality for interrogating, manipulating and working with JSON file. jq can do a lot but probably the highest ...