Hacker News new | past | comments | ask | show | jobs | submit login
Show HN: Jless, a command-line JSON viewer (pauljuliusmartinez.github.io)
344 points by CodeIsTheEnd on Feb 11, 2022 | hide | past | favorite | 84 comments
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




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.


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.


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.


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


Humble request: musl version

Keeping a glibc chroot directory takes up a fair bit of space, leaving less space available for other stuff.

Whenever I try compiling Rust programs it exhausts the available space I have.

Hence I am resorting to begging, starting now (because this program sounds potentially very useful.) Please folks, if possible, include musl versions in addition to glibc. :)


It's 2022 and you're running out of disk space?


Yes, the same reason that programs remain slow, even though computers keep getting faster.


I don't think that's the reason... It's because so called modern stacks are built on 100 layers of abstractions instead of being low level and fast.


One might want to include jless in a docker image.


Nice! I’ve been using jsonfui[1] which does something similar but will definitely give this a go

[1] https://github.com/AdrianSchneider/jsonfui


Also worth mentioning: https://github.com/antonmedv/fx


Can you pipe output from another command to jless and have it detect when it finds a JSON document? I often tail the logs of my servers and then need to inspect the JSON data from say an API call. I usually do that by copying the entirety of the log into a bug report and then extracting the relevant pieces out and then using jq and it's a big hassle. Could I use jless to make this easier?

Really nice looking tool and awesome home page. It's so nice when a tool immediately shows you exactly what makes it special (instead of giving you dozens of installation notes, etc...)


For this specific use case there are log view tools that allow you to navigate logs and can automatically format json, xml etc when inside a log line. For example lnav: https://lnav.org/features#pretty-print-view


FWIW I was unable to install it on Mac using cargo which compiles it from Rust. Here is the error I got.

    error[E0658]: or-patterns syntax is experimental
       --> /Users/xxxx/.cargo/registry/src/github.com-1ecc6299db9ec823/jless-0.7.1/src/app.rs:101:26
        |
    101 |                 KeyEvent(Key::Ctrl('c') | Key::Char('q')) => break,
        |                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        |
        = note: see issue #54883 <https://github.com/rust-lang/rust/issues/54883> for more information

    error[E0658]: or-patterns syntax is experimental
      --> /Users/xxxx/.cargo/registry/src/github.com-1ecc6299db9ec823/jless-0.7.1/src/jsonparser.rs:67:24
       |
    67 |         while let Some(JsonToken::Whitespace | JsonToken::Newline) = self.peek_token_or_eof() {
       |                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
       |
       = note: see issue #54883 <https://github.com/rust-lang/rust/issues/54883> for more information

    error: aborting due to 2 previous errors

    For more information about this error, try `rustc --explain E0658`.
    error: failed to compile `jless v0.7.1`, intermediate artifacts can be found at `/var/folders/7n/jbbdpxnj373d5trx65_bryhr0000gr/T/cargo-installUE4dQ5`

    Caused by:
      could not compile `jless`


Seems like your Rust version is a bit out of date. Nested or-patterns have been stabilised in Rust 1.53.0, which came out back in June.


Another useful tool for working with JSON interactively is ijq: https://github.com/gpanders/ijq


Looks great but odd choice for packaging only on MacPorts and Nix.


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!


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!


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...


Here are a couple of options if anyone is curious: https://github.com/johnthagen/min-sized-rust


FWIW, when rebuilding jless with some of the cargo tweaks mentioned here, as well as in https://www.collabora.com/news-and-blog/blog/2020/04/28/redu..., I managed to get the binary size down to 1.75MB. Better, but still huge.

Note that I did not use tweaks which require rust nightly, as I did not feel like installing it.


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.


This looks really good! Thanks a lot.

What i am always missing (fx & friends) is a preview and gradual expand. If you should feel inclined, you may want to look at jsonui[1] which has this (with C => e e e). Even if it is rather crude, I always come back to if for these two features

[1] https://github.com/gulyasm/jsonui


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 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.


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 :)


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.


Nice, much appreciated! This is handy for inspecting some large binary objects to json dumps I had wanted to examine.


on a related note, where do people find artists to make logos/mascots like that?


I browsed Fiverr to find a few artists whose styles were similar to what I had in mind, then messaged a few of them. annatgraphics [1] was able to take my crude color pencil sketches and turn them into the slick art you see today!

[1]: https://www.fiverr.com/annatgraphics


I'd love to see YAML support.

I can see this being useful on a daily basis for everyone who works with Kubernetes.

It's so useful that I'm going to dedicate next episode of my 100 Kubernetes Tool series to this. [1]

[1] https://youtube.com/playlist?list=PLxKcdWncGLlNiWC71kKwDj3OZ...


Theres some 'jq for yaml/toml' projects that just convert to and from json and then use jq in the middle, seems like that would work here too.


Yeah, you can also get kubectl to output json directly


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!


This is awesome! A great add to our command line utilities!


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.


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!


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.


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


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.


Really love this. The navigation is very cool.


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.


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.


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


They could have sent the link to friends, some of which did not have an account yet but wanted to comment?


[flagged]


The same guidelines also explicitly say not to post accusations like yours. If you suspect abuse, email the mods.


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


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)


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 give him credit for planning ahead.


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.


Oh no. ¯\_(ツ)_/¯


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.


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?


You might be onto something. See https://www.jeffgeerling.com/blog/2022/i-almost-got-banned-h...

But messaging the mods to investigate is the better strategy.


I feel like we get json command line tool every week




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: