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
Discussions

Format json using jq
A quick google says "A positional parameter cannot be found that accepts argument" is an error returned from PowerShell. Maybe this will help https://vi.stackexchange.com/questions/35132/make-work-with-powershell-neovim More on reddit.com
🌐 r/neovim
8
4
July 6, 2022
json - jq to replace text directly on file (like sed -i) - Stack Overflow
While this command makes the needed ... entire json on the terminal and does not make change to the file itself. Please advise if there is an option to have jq make changes on the file directly (similar to sed -i). ... For a number of general solutions to "how do I change a file in-place" see also ... More on stackoverflow.com
🌐 stackoverflow.com
bash - How to format a JSON string as a table using jq? - Stack Overflow
I think I want to get these values ... do the formatting...? The things I tried give me varying results, but never what I really want. ... Could you add some sample output of your jq -r ... command? ... Your use of echo can be avoided jq -r '...' <<<$data or jr -r '...' < input-file.json... More on stackoverflow.com
🌐 stackoverflow.com
Editing json file in line with jq - Stack Overflow
I want to change the type to something ... in their place with a value. ... Do you want this to affect all items in .arrays or just those that match .name == "foo"? Do you want to change all items of the .properties array, or just those that match .type == "app"? Are there other fields in those items that you want to keep, so .url and .checksum have to be explicitly deleted, or could you build a new object just containing the altered .type and the added .file fields? ... jq '(.arrays[]| ... More on stackoverflow.com
🌐 stackoverflow.com
🌐
Reddit
reddit.com › r/neovim › format json using jq
r/neovim on Reddit: Format json using jq
July 6, 2022 -

Hey all,

I have this mapping, which worked for a long time, and recently stopped working for me:

nnoremap <leader>=j :%!jq --tab .<cr>:%s/\r<cr>

This sends my file to jq, uses tabs for indent and formats the file, and then I remove `\r` throughout the file.

The problem I'm now having is I get the following error when it's run:

:%!jq --tab .
shell returned 1

:%s/\r/e

When I press enter, I get the shell error:

Start-Process: A positional parameter cannot be found that accepts argument '.'.e

I run Neovim 0.7.2, in Windows. I've set my Neovim shell to be PowerShell.

This used to work, and I've just verified that this workes in Neovim 0.7.0.

Does anyone know of anything that changed that I need to take into account in my mapping? Or do you think that they somehow broke something in 0.7.2?

Cheers,

🌐
DigitalOcean
digitalocean.com › community › tutorials › how-to-transform-json-data-with-jq
How To Transform JSON Data with jq | DigitalOcean
September 23, 2025 - In this comprehensive article, you will use jq to transform a sample JSON file about ocean animals, then progress to advanced techniques including AI integration, performance optimization, and real-world production scenarios. You’ll apply data transformations using filters, merge pieces of transformed data into new data structures, and learn how to integrate jq into modern AI and DevOps workflows.
🌐
Codegoalie
codegoalie.com › posts › format-json-nvim-jq
Format JSON in Nvim with jq · CodeGoalie
February 12, 2024 - Using jq externally. cat input.json | jq . > output.json. This kind of sucks because you now have 2 files… · Now, you can open the file in neovim and type :%!jq .. Magically, the buffer will be nicely formatted.
🌐
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.
Find elsewhere
🌐
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.
🌐
LornaJane
lornajane.net › posts › 2024 › pretty-print-json-with-jq
Pretty-print JSON with jq | LornaJane
Wrangling some document conversion ... 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. For the impatient, here’s the command: ... In this post we’ll look at the data I started with and what the different bits of the command to do help. My data looked like this (actually I was working with an OpenAPI file, which was ...
🌐
Shapeshed
shapeshed.com › jq-json
JSON on the command line with jq | George Ornbo
September 19, 2024 - This can be very useful in data transform pipelines to shift JSON data from one structure to another. jq can also operate on data within JSON objects. Suppose the following JSON file exists and is saved as inventory.json.
🌐
jq
jqlang.org
jq
jq is like sed for JSON data - you can use it to slice and filter and map and transform structured data with the same ease that sed, awk, grep and friends let you play with text. jq is written in portable C, and it has zero runtime dependencies.
🌐
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 - This means that working with JSON via the command line can be cumbersome, involving text manipulation using a combination of tools such as sed and grep. Learn several ways to pretty-print an XML file using Linux commands ... In this tutorial, we’ll look at how we can alleviate this awkwardness using jq — an eloquent command-line processor for JSON.
🌐
Medium
medium.com › @buczynski.rafal › exploring-jq-a-guide-to-essential-techniques-and-tools-for-professionals-b9df9db490de
Exploring jq: A Guide to Essential Techniques and Tools for Professionals | by Rafał Buczyński | Medium
December 17, 2025 - To get a feel for how jq works, let’s start with a basic command to read and display JSON data. Suppose you have a JSON file named data.json. To display the content of this file in a formatted manner, you can use the following jq command:
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",$1,$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]"
]
🌐
+234 Developer
234developer.wordpress.com › 2022 › 10 › 02 › how-to-format-prettify-a-json-file-in-place-using-jq
How to format/prettify a json file in-place using jq. | +234 Developer
October 2, 2022 - A very simple way to achive in-place editing with jq using cat tool is to understand linux redirection, what we will do is to apply jq to the file, then redirect the output to cat and then finally redirect the output to the same filename as shown ...
🌐
Michaelheap
michaelheap.com › set-value-with-jq
Set a value in place with `jq` | michaelheap.com
To update a file's contents without a temporary file you need to use cat and a sub-shell: ... cat <<< "$(jq '.scripts.build = "npx @vercel/ncc build && npx convert-action"' package.json)" &gt; package.json · This will set .scripts.build in package.json in-place.
🌐
jq
jqlang.org › manual
jq 1.8 Manual
If you run jq with --rawfile foo bar, then $foo is available in the program and has a string whose content is set to the text in the file named bar. ... Remaining arguments are positional string arguments. These are available to the jq program as $ARGS.positional[]. ... Remaining arguments are positional JSON text arguments.
🌐
~/.didev
davidisaksson.dev › posts › format json in vim with jq
Format JSON in Vim with jq | ~/.didev
April 13, 2023 - I use the abbreviations fj for “format JSON” and fcj for “format compact JSON”, but feel free to choose any abbreviations that works best for you. " Whole buffer nnoremap <silent> <Leader>fj <Cmd>%!jq<CR> nnoremap <silent> <Leader>fcj <Cmd>%!jq --compact-output<CR> " Visual selection vnoremap <silent> <Leader>fj :'<,'>!jq<CR> vnoremap <silent> <Leader>fcj :'<,'>!jq --compact-output<CR>