Show HN: Jless, a command-line JSON viewer (pauljuliusmartinez.github.io)

344 points by CodeIsTheEnd ↗ HN
Hey, Hacker News! Today I'm proud to release jless, a command-line JSON viewer.

jless provides a JSON viewing experience similar to what you see in a browser's network tab in the developer console, but from the comfort of your terminal, with a whole suite of vim-inspired key bindings to easily manipulate your view of the data and full-text regex search. I'm sure many of you have some piped together some combination of cat, jq and less before; hopefully jless can replace that usage (hence the name). It supports newline delimited JSON too, so it can handle any output from jq.

I built jless to solve a problem I kept facing while building plaintextsports.com [1][2]. For the live data I use a lot of public, but undocumented APIs, and I was constantly digging through giant JSON files to understand how the data was structured. I tried installing multiple Chrome extensions, but was dissatisfied with all of them. I piped files through jq into less a lot, and that was ok, but not great. The Preview pane in the Network tab of Chrome's dev tools was pretty useful, and I modeled a lot of jless's behavior and appearance off of that, but it didn't fit well into my tmux + vim dev environment, and I couldn't easily use it to inspect files on disk. I wanted that experience, but in my terminal (and with search support).

Once I had built a rudimentary version of jless a few months ago, I immediately started using it whenever I was debugging something, and my usage has only grown as I've added more basic functionality. I've finally added all the features I feel like it needs to be functional, useful, and reliable.

There's definitely more features I want to add: Windows support, some way to filter data with jq filters (a la fx [3]), yanking objects to the clipboard, being able to hide keys entirely, streaming data in, so you can peek at the start of gigantic file, maybe a way to extract a schema from a file (like [4]), plenty of low-hanging fruit for performance. Support for different hierarchical data formats (YAML, TOML, XML) could be cool someday. I'm sure many people will ask for editing support, but sadly that is not something I plan on adding anytime soon.

I also used this project as a chance to learn Rust (code style and design comments appreciated!), which I had only dabbled with before. For a command-line utility, this felt like an obvious choice: small binaries (~3mb), instant startup, and great performance without any effort (try searching for comma in a big file!).

I hope you find it useful!

[1]: https://plaintextsports.com, live sports scores in plain text, no ads, no tracking, no loading

[2]: https://news.ycombinator.com/item?id=26310314

[3]: https://news.ycombinator.com/item?id=29861043

[4]: https://quicktype.io/typescript

90 comments

[ 129 ms ] story [ 1847 ms ] thread
(comment deleted)
This is great, especially for when I'm trying to digest a big blob where I don't know exactly what the structure is already!
Love it! It's nice that you can pipe to jless the same way you would pipe to less. Super useful for navigating through kube resources, eg:

kubectl get pod mypod-0 -n namespace0 -o json | jless

ive used this. its awesome!!
Welcome to HN. Sorry some nasty people in the community think you're a fake account. I don't think so. I think you're probably just lurking for many years.
Relied on this a lot while working on a web scraping project! Crazy useful for quickly parsing long JSON responses.
Awesome! I'm sorry that some creeper singled out your comment as being from a fake account. I think you're just a long time non-commenting participant. Their behavior is not welcome here, and against the site rules, and there's no way they actually have the data to make that claim--but people still make such mean comments sometimes. Sorry you had to face that today.
Such a dope and useful tool, gonna be using it a bunch :)
Welcome to HN :) There's always weirdos looking to hate on stuff here, but you didn't deserve to be called a fake account. I think you just read but don't comment. The mean people are just projecting, and suspecting others of what they themselves would do. Sorry they did that to you today.
This is a lovely product. I would like to use it and compare to jq, which I already use to query the contents of a JSON structure from the CLI.
> This is a lovely product

It's a lovely project, a lovely tool.

I think calling it a "product" devalues it, implies it's being used to sell something or exploit its users.

Glad I fought the reflex to jump straight into the comments with "So how is this different than jq" and instead actually clicked through to see the wonderful homepage that instantly answered my question via animated GIF. I'm a sucker for trying out any new CLI tool and this looks genuinely and immediately useful. Thanks!
Excellent! The expected future value of the comment thread thanks you for that sterling effort.

It was a pretty wonderful homepage right? I don't have any need for it now whatsoever, but this project looks like a useful debugging tool if you need to reverse engineer undocumented APIs. And the author's write up is comprehensive informative and well written. And their site looks good so this is an awesome Show HN I think.

That's one of the most informative and compact pages about a tool that I've ever seen. Compliments to whoever made it!
It's so good, it's convinced me to add asciinema recordings to more of my utilities. The only problem is that they tend to get stale.
Clearly there should be integration tests/automation that outputs asciinema examples?
How do you mean? Is a log not basically the same?
I mean that if asciinema examples in the readme tends to get outdated (ed2: "stale") , they should be kept up to date via CI and (probably) be part of the integration tests; if a commit changes the ux/interaction tests should reflect that, and documentation should be easily (automatically) updated?

Ed: like if you for a web app have selenium/browser tests that somehow also takes screenshots that become part of the documentation?

Ah, I see. That's probably a bit too much tooling for a small OSS utility, manual updates would get me a long way there. The other issue is that it doesn't matter that the UI is exactly up to date, just good enough to give the user an idea of the functionality.
It's a generally good idea though, website screenshots (and thinking about it now, animations) from test automation is another similar task.

Not quite standard practice, though some people do bits of it here and there, but both probably should become so which would amortize the cost over lots of cli tools.

Homebrew?
That's certainly the plan! I've never released a project like this, so I wasn't sure what the process is for adding things to Homebrew, or other package managers. A few people have been really helpful and already added it to Arch Linux and NetBSD's package managers.

This week I just wanted to get the project out there to see if people liked it, so I compiled stuff locally and manually uploaded them to the GitHub releases page. I'll spend some time over the next few weeks figuring out how to automate a lot of these things.

Very nice! I also thought "how is this different than jq" - glad I clicked on the link - this will be very helpful in my toolset! Thanks!
This looks great. So far the only tools I have are:

  function jql() { jq -C "$@" | less -R ; }
and an abuse of the preview feature in fzf room let you interactively write a jq query.
Consider adding "gron" to your toolset, for easy json processing in the command line. It is cruder than jq, but it has a nice aura of simplicity that jq lacks.
gron is wonderful for

    gron | rg <some fragment> | gron -u
which gives you a structurally accurate subset of a json document.
I do exactly this, and I’m very happy with it. I tried switching to another tool like Jless when it got posted on HN last year, but it wasn’t enough of a game-changer compared to jq itself.

I don’t get to interactively change the query, but hitting ‘q’ and running another jq query is in some sense more powerful, because it does not just allow me to “focus the lens” but also completely alter it.

Building a jq query by progressively testing and viewing is really nice. I love jq!

What are the odds that 3 separate, years-old accounts came out of the woodworks within the last hour to make their only comments of all time to support this post? 3/14 of the only comments as I make this...

https://news.ycombinator.com/item?id=30275812

https://news.ycombinator.com/item?id=30280084

https://news.ycombinator.com/item?id=30277488

You go to do what you go to do to promote your side hustle :)
>You go to do what you go to do to promote your side hustle :)

No, not here.

Its "Show HN..."
And here it's directly mentioned in the guidelines of how 'Show HN' should work:

https://news.ycombinator.com/showhn.html

> Please don't ask friends to upvote or comment. That's not ok on HN.

https://news.ycombinator.com/newsfaq.html#ring

> Can I ask people to upvote my submission?

> No. Users should vote for a story because they personally find it intellectually interesting, not because someone has content to promote. We penalize or ban submissions, accounts, and sites that break this rule, so please don't.

> Can I ask people to comment on my submission?

> No, for the same reason. It's also not in your interest: HN readers are sensitive to this and will detect it, flag it, and use unkind words like 'spam'.

You've basically turned an entire sub-thread on a Show HN into a low-quality distraction based on your un-provable (to you) accusation, and subsequent doubling down...all of which, as multiple people have tried to remind you, is breaking the rules:

https://news.ycombinator.com/newsguidelines.html#:~:text=Ple....

Also, you can't cite the rules as some fake justification for your flouting the rules. Abusing the rules to pretend that, because the thing you, without proof, accuse someone of is disallowed, it somehow makes it OK for you to break the rules to post these disallowed accusations...is wrong. You're undermining the very thing you're merely pretending to support here. Which makes it seem like you never cared much for the rules in the first place, but only for some weird personal vendetta or whatever against this post. Whatever your reason, none of this is OK, on HN. Or anywhere really.

Please stop.

You either automated your lazyness out of busting fake praising accounts or what are the odds someone will spend their time browsing commenters' profiles to catch this? lol

I appreciate the effort and good will

They could have sent the link to friends, some of which did not have an account yet but wanted to comment?
The same guidelines also explicitly say not to post accusations like yours. If you suspect abuse, email the mods.
Ha! Says the anon account with not even two pages of comments in 4 years

Why not use your real identity if you're so confident your claim is good?

That's pretty creepy and a bit disgusting to post that on someone's Show HN. Be a nicer human!

Tho.. Yeah... Sadly it does say something about how much HN can still improve it's response to Shows that people get so suspicious if there's too many positive comments and not enough negative ones--that they go looking for 'proof'.

My claim? My post said - what are the odds all of these old accounts appeared out of the blue to post their first comment here? If you are taking that question as a personal insult, I'm sorry you feel that way.
Haha, you know you can't apologize for someone's feelings, right? Their feelings are their responsibility, not yours. But your actions are your responsibility. Trying to incorrectly apologize for someone else's feelings is not owning your responsibility, and doubly bad because you seem to suggest that the problem is not your action but someone else's reaction which is incorrect. So if you feel you need to apologize, you can only do so for your actions. Got it? So go ahead, if you want to apologize, your can say, "I'm sorry for posting that"

The problem with that post is it's unnecessarily mean and you don't actually have any data to back up that claim, it's just speculation and a nasty one at that. It degrades the tone of discussion on a Show HN which is inappropriate, and is not what is aimed for here. If you feel there's an issue then email the mods, as they can take a look at the real data. Don't make baseless and cruel speculation on someone showing their work. Got it?

I mean OK, cool, you have checked, but IMO that's not very relevant.

I genuinely enjoyed the promo site and immediately installed the tool and tried it and loved it. Check my comment history if you like, not a bot or anything, just a normal programmer always in need of more tools to enable and improve his work.

(comment deleted)
Isn't it also against Hacker News policy to go posting comments accusing other commenters as fake?

It just degrades the discussion as seen here.

Also, pretty sure that Hacker News has automatic detection for fake comments so no need to do manual moderating I think.

I have no idea about the odds and didn't bother to look up the timeline but I can give you some anecdata and tell you exactly why I might have theoretically been the 4th lurker-become-excited-commenter for this post, were I to read this first on the computer instead of on my phone (and nearer real time than on a following weekend) and less hesitant to post comments in general:

I find json to be a PITA to parse as a human when looking at getting a bigger picture or keys/values that are strewn away from each other and not just e.g. two values next to each other. Anytime I have to do something with it, I have to search through my history to dig out some jq invocation and then try to tweak it correctly to do what the (most of the time similar but also different enough) task at hand needs. My mind sadly just seems to be unable to sufficiently grok jq.

So when I read here about jless I was stoked and the excitement was strong enough to want to dig out my login credentials and make a comment along the lines of "This is AWESOME! Thank you so much for making life easier!". In the end, when I logged in on the computer and had reflected more, I opted to upvote a comment instead and then saw this thread; so thank you, I guess, for providing me an opportunity or excuse to express my enthusiasm in addition to that.

I consider my discovery of jless (which sadly I was apparently not able to make on my own while searching the internet for json tools previously - so yay for lurking on HN :-) - but it might also partly be the relative (to my predicament) youth of the tool) of similar importance to me as macros in vim or back in the days using bluefish for editing HTML as they all save my time being spent on doing tooling to do things and instead allow it to being spent on doing things directly. (BTW thanks to all these devs!)

Just my 2 cents :-) (and I'm not particularly interested in starting or partaking in any further discussion)

One tool I rely on when I need to understand the structure of JSON is gron. I haven’t tried jless yet, will definitely do, but if you’re looking for inspiration, the gron representation is really useful.
I use a similar tool in a browser all the time, so I definitely have a need for this tool, and this is much better than a browser tool. Thank you for this effort!
Nice, much appreciated! This is handy for inspecting some large binary objects to json dumps I had wanted to examine.
I feel like we get json command line tool every week
I'm loving it, and certainly will be using it a lot. One thing, though - 2MB seems like a lot for program of this kind. In comparison, jq on my system has 30kB.
I'll bet there are some Rust build options they can tweak to get it way down...
I'll bet that a good project for a different person who has idly thought "y'know, I'd like an excuse to learn rust..." could be doing that.
Super cool OP! Love the home page and the demo gif! Love this!
Every now and then you just randomly look at HN, stumble upon a tool, read the home page and just 20% in you are gasping "OMG HOW DID I LIVE WITHOUT THIS!".

Yep, `jless` is exactly that kind of tool. Instant favourite, and love at first sight.

Extremely good job, thanks a lot for the tool!

Wow, thank you so much for sharing this. I'm a frequent jq-to-less piper and probably a more frequent mobile browsing opener of ESPN scoreboards/subsequent grumbler about ESPN's web performance and experience. I think I'll get a lot of mileage out of plaintextsports as long as it stays up. I will also be sure to check out Jless next time I'm at my command line with sufficient bandwidth to tinker with my tooling/workflow. Cheers!
thanks for plaintextsports too!

don't know what's going on inside of espn but their web experience (mobile or not) is just terrible - and i don't bother with the app. was really looking for something like how simple yahoo sports was back in the day, and plaintextsports seems to be it.

Thanks to the both of you! plaintextsports was my real passion project over the past year (probably 3x more time spent on it than jless!), so I really appreciate it when other people find value in it. I'm a Milwaukee Bucks fan and building a site explicitly so I could follow the team more easily certainly made winning the championship more personally meaningful.
This is awesome! A great add to our command line utilities!
This is great! I use the JSONVue Chrome extension at work to display JSON files, and I can see the similarities.

If I could suggest one thing: ctrl-u and ctrl-d are pretty common shortcuts for page up and page down, they're even supported in Vim and less. It would make sense to add support for those in addition to the actual PageUp/PageDown keys.

Yup, someone already made a PR for to add these! It turns out the behavior is pretty subtle in terms of how it handles count arguments (it's actually stateful!), and where the focus moves. I'll take some time to figure out how to exactly match the vim/less behavior, but that should be coming soon!

I'm more of a ctrl-e/ctrl-y guy myself, so I didn't feel a need to implement these commands right away.

Maybe hijacking the thread, but if you prefer to stay in the browser give also a try to Virtual Json Viewer extension [1][2]. I developed it to navigate large json files at work and it also integrates JQ.

unrelated: this is my very first comment on HN, hurray!

[1] Chrome Web Store: https://chrome.google.com/webstore/detail/virtual-json-viewe...

[2] Github: https://github.com/paolosimone/virtual-json-viewer

I only saw your comment after a day and just tried your extension, it works great! I really like how much faster it is than JSONVue, and the JQ integration looks super useful; this is a really good start.

Oh and welcome to HN :)

This is great. I just wish it was called "jess", it would be a much cooler name!