3/27/2026 at 1:43:02 PM
Jq's syntax is so arcane I can never remember it and always need to look up how to get a value from simple JSON.by regus
3/27/2026 at 7:56:23 PM
Funny that everyone is linking the tools they wrote for themselves to deal with this problem. I am no exception. I wrote one that just lets you write JavaScript. Imagine my surprise that this extremely naive implementation was faster than jq, even on large files. $ cat package.json | dq 'Object.keys(data).slice(0, 5)'
[ "name", "type", "version", "scripts", "dependencies" ]
https://crespo.business/posts/dq-its-just-js/
by dcre
3/27/2026 at 2:57:26 PM
That’s interesting! Can you say a little more? I find jq’s syntax and semantics to be simple and intuitive. It’s mostly dots, pipes, and brackets. It’s a lot like writing shell pipelines imo. And I tend to use it in the same way. Lots of one-time use invocations, so I spend more time writing jq filters than I spend reading them.I suspect my use cases are less complex than yours. Or maybe jq just fits the way I think for some reason.
I dream of a world in which all CLI tools produce and consume JSON and we use jq to glue them together. Sounds like that would be a nightmare for you.
by d35007
3/27/2026 at 3:46:36 PM
I'm not GP, I use jq all the time, but I each time I use it I feel like I'm still a beginner because I don't get where I want to go on the first several attempts. Great tool, but IMO it is more intuitive to JSON people that want a CLI tool than CLI people that want a JSON tool. In other words, I have my own preconceptions about how piping should work on the whole thing, not iterating, and it always trips me up.Here's an example of my white whale, converting JSON arrays to TSV.
cat input.json | jq -S '(first|keys | map({key: ., value: .}) | from_entries), (.[])' | jq -r '[.[]] | @tsv' > out.tsv
by randusername
3/27/2026 at 6:55:29 PM
<input.json jq -S -r '(first | keys) , (.[]| [.[]]) | @tsv'
<input.json # redir
jq
-S # sort
-r # raw string out
'
(first | keys) # header
, # comma is generator
(.[] | # loop input array and bind to .
[ # construct array
.[] # with items being the array of values of the bound object
])
| @tsv' # generator binds the above array to . and renders to tsv
by nh23423fefe
3/27/2026 at 7:48:50 PM
oh my god how could I have been doing this for so long and not realize that you can redirect before your binary.I knew cat was an anti-pattern, but I always thought it was so unreadable to redirect at the end
by randusername
3/27/2026 at 5:39:51 PM
Here's an easier to understand query for what you're trying to do (at least it's easier to understand for me): cat input.json | jq -r '(first | keys) as $cols | $cols, (.[] | [.[$cols[]]]) | @tsv'
That whole map and from entries throws it off. It's not a good use for what you're doing. tsv expects a bunch of arrays, whereas you're getting a bunch of objects (with the header also being one) and then converting them to arrays. That is an unnecessary step and makes it a little harder to understand.
by figmert
3/27/2026 at 5:54:59 PM
Thanks for sharing, this is much better, though I actually think it is the perfect example to explain something that is brain-slippery about jqlook at $cols | $cols
my brain says hmm that's a typo, clearly they meant ; instead of | because nothing is getting piped, we just have two separate statements. Surely the assignment "exhausts the pipeline" and we're only passing null downstream
the pipelining has some implicit contextual stuff going on that I have to arrive at by trial and error each time since it doesn't fit in my worldview while I'm doing other shell stuff
by randusername
3/27/2026 at 7:49:25 PM
Honestly both of those make me do the confused-dog-head-tilt thing. I'd go for something sexp based, perhaps with infix composition, map, and flatmap operators as sugar.by chuckadams
3/27/2026 at 4:39:00 PM
I find it much harder to remember / use each time then awkby lokar
3/27/2026 at 4:35:50 PM
Sound similar to how power shell works, and it’s not great. Plain text is better.by stingraycharles
3/27/2026 at 5:16:22 PM
I think the big problem is it's a tool you usually reach for so rarely you never quite get the opportunity to really learn it well, so it always remains in that valley of despair where you know you should use it, but it's never intuitive or easy to use.It's not unique in that regard. 'sed' is Turing complete[1][2], but few people get farther than learning how to do a basic regex substitution.
[1] https://catonmat.net/proof-that-sed-is-turing-complete
[1] And arguably a Turing tarpit.
by marginalia_nu
3/27/2026 at 7:54:24 PM
I was just going to say, jq is like sed in that I only use 1% of it 99% of the time, but unlike sed in that I'm not aware of any clearly better if less ubiquitous alternatives to the 1% (e.g., Perl or ripgrep for simple regex substitutions in pipelines because better regex dialects).Closest I've come, if you're willing to overlook its verbosity and (lack of) speed, is actually PowerShell, if only because it's a bit nicer than Python or JavaScript for interactive use.
by jasomill
3/27/2026 at 2:16:10 PM
Shameless plug, but you might like this: https://github.com/IvanIsCoding/celqjq is the CLI I like the most, but sometimes even I struggled to understand the queries I wrote in the past. celq uses a more familiar language (CEL)
by ivaniscoding
3/27/2026 at 2:37:17 PM
Cool tool! Really appreciate the shoutout to gron in the readme, thanks! :)by TomNomNom
3/27/2026 at 3:03:54 PM
I had never heard of CEL, looks useful though, thanks for posting this!by bigfishrunning
3/27/2026 at 2:28:25 PM
CEL looks interesting and useful, though it isn't common nor familiar imo (not for me at least). Quoting from https://github.com/google/cel-spec # Common Expression Language
The Common Expression Language (CEL) implements common
semantics for expression evaluation, enabling different
applications to more easily interoperate.
## Key Applications
- Security policy: organizations have complex infrastructure
and need common tooling to reason about the system as a whole
- Protocols: expressions are a useful data type and require
interoperability across programming languages and platforms.
by xpe
3/27/2026 at 2:54:01 PM
That’s some fair criticism, but the same page tells that the language wanted to have a similar syntax to C and JavaScript.I think my personal preference for syntax would be Python’s. One day I want to try writing a query tool with https://github.com/pydantic/monty
by ivaniscoding
3/27/2026 at 7:39:28 PM
Like I did with regex some years earlier, I worked on a project for a few weeks that required constant interactions with jq, and through that I managed to lock in the general shape of queries so that my google hints became much faster.Of course, this doesn't matter now, I just ask an LLM to make the query for me if it's so complex that I can't do it by hand within seconds.
by raydev
3/27/2026 at 7:51:43 PM
I completely agree. I much prefer leveraging actual javascript to get what I need instead of spending time trying to fumble my way through jq syntax.by LgWoodenBadger
3/27/2026 at 7:57:34 PM
Check this out: https://crespo.business/posts/dq-its-just-js/You don't have to use my implementation, you could easily write your own.
by dcre
3/27/2026 at 6:19:13 PM
To fix this I recently made myself a tiny tool I called jtree that recursively walks json, spitting out one line per leaf. Each line is the jq selector and leaf value separated by "=".No more fiddling around trying to figure out the damn selector by trying to track the indentation level across a huge file. Also easy to pipe into fzf, then split on "=", trim, then pass to jq
by epr
3/27/2026 at 6:28:30 PM
You might like https://github.com/tomnomnom/gronby iamjackg
3/27/2026 at 7:18:06 PM
I agree, even trivial tasks require us to go back to jq's manual to learn how to write their language.this and other reasons is why I built: https://github.com/dhuan/dop
by dhuan_
3/27/2026 at 5:17:36 PM
If we're plugging jq alternatives, I'll plug my own: https://git.sr.ht/~charles/rqI was working at lot with Rego (the DSL for Open Policy Agent) and realized it was actually a pretty nice syntax for jq type use cases.
by charlesdaniels
3/27/2026 at 4:31:15 PM
Highly recommend gron. https://github.com/tomnomnom/gronby xendo
3/27/2026 at 5:00:02 PM
or https://github.com/adamritter/fastgronby eevmanu
3/27/2026 at 4:10:34 PM
JMESPath is what I wish jq was. Consistent grammar. It only issue is it lacks the ability to convert JSON to other formats like CSV.by janderland
3/27/2026 at 3:36:02 PM
I just ask Opus to generate the queries for me these days.by voidfunc
3/27/2026 at 3:26:26 PM
LOL ... I can absolutely feel your pain. That's exactly why I created for myself a graphical approach. I shared the first version with friends and it turned into "ColumnLens" (ImGUI on Mac) app. Here is a use case from the healthcare industry: https://columnlens.com/industries/medicalby hilti
3/27/2026 at 1:58:54 PM
I also genuinely hate using jq. It is one of the only things that I rely heavily on AI.by NSPG911
3/27/2026 at 3:06:09 PM
You should try nushell or PowerShell which have built ins to convert json to objects. It makes it so easy.by vips7L
3/27/2026 at 3:19:27 PM
Second this. Working with nushell is a joy.by bigstrat2003
3/27/2026 at 2:27:47 PM
At that point why don't we ask the AI directly to filter through our data? The AI query language is much more powerful.by amelius
3/27/2026 at 2:50:08 PM
Because the output you get can have hallucinations, which don’t happen with a deterministic tool. Furthermore, by getting the `jq` command you get something which is reusable, fast, offline, local, doesn’t send your data to a third-party, doesn’t waste a bunch of tokens, … Using an LLM to filter the data is worse in every metric.by latexr
3/27/2026 at 5:05:06 PM
I get that AI isn’t deterministic by definition, but IMHO it’s become the go-to response for a reason to not use AI, regardless of the use case.I’ve never seen AI “hallucinate” on basic data transformation tasks. If you tell it to convert JSON to YAML, that’s what you’re going to get. Most LLMs are probably using something like jq to do the conversion in the background anyway.
AI experts say AI models don’t hallucinate, they confabulate.
by alwillis
3/27/2026 at 6:50:55 PM
Just because you haven't seen it hallucinate on these tasks doesn't mean it can't.When I'm deciding what tool to use, my question is "does this need AI?", not "could AI solve this?" There's plenty of cases where its hard to write a deterministic script to do something, but if there is a deterministic option, why would you choose something that might give you the wrong answer? It's also more expensive.
The jq script or other script that an LLM generates is way easier to spot check than the output if you ask it to transform the data directly, and you can reuse it.
by tkclough
3/27/2026 at 2:52:08 PM
You can use a local LLM and you can ask it to use tools so it is faster.by amelius
3/27/2026 at 3:38:46 PM
"so it is faster" than what? A cloud hosted LLM? That's a pretty low bar. It's certainly not faster than jq.by sigseg1v
3/27/2026 at 2:59:55 PM
There is hardware that is able to run jq but no a local AI model that's powerful enough to make the filtering reliable. Ex a raspberry piby kelvinjps10
3/27/2026 at 3:04:38 PM
Because the input might be sensitive.Because the input might be huge.
Because there is a risk of getting hallucinations in the output.
Isn't this obvious?
by imcritic
3/27/2026 at 4:22:55 PM
...and because it's going to burn a million times the energy of what jq would require.by aduitsis
3/27/2026 at 2:58:30 PM
You really need to go and learn about the concept of determinism and why for some tasks we need and want deterministic solutions.It's an important idea in computer science. Go and learn.
by Shorel
3/27/2026 at 3:04:45 PM
You need to learn to adapt to the real world where most things are not deterministic. Go and learn.by amelius
3/27/2026 at 3:39:29 PM
I already know that. That's why we have deterministic algorithms, to simplify that complexity. You have much to learn, witty answers mean nothing here, particularly empty witty answers, which are no better than jokes. Maybe stand-up comedy is your call in life.by Shorel
3/27/2026 at 3:24:11 PM
That may be true, but do you not want determinism where possible, especially within this context, i.e. filtering data?by johnisgood
3/27/2026 at 3:28:11 PM
Is your argument that the world isn't deterministic and so we should also apply nondeterminism to filtering json data?by skipants
3/27/2026 at 3:41:18 PM
yeah I literally just use gemini / claude to one-shot JQ queries nowby GaryNumanVevo
3/27/2026 at 2:29:09 PM
[flagged]by d0963319287