from Hacker News

Fx – Terminal JSON Viewer

by medv on 9/19/23, 8:26 AM with 78 comments

  • by medv on 9/19/23, 8:28 AM

    Hey HN friends!

    I've taken `fx` back to the drawing board and completely rewritten it from the ground up. Excited to share what's new:

    1. *Going Big*: `fx` now gracefully handles even the most massive JSON files.

    2. *A New TUI Look*: Dive deep into your data with a revamped terminal interface—now with themes!

    3. *Swift Navigation with Dig Fuzzy Search*: Feeling lost in JSON? Just type `.` and navigate with ease.

    4. *Powerful Regex Search*: Scan across your entire JSON content with precision.

    5. *Elegant Long String Wraps*: No more cut-offs. Your strings wrap beautifully now.

    6. *All Things JSON*: Added love for comments, trailing commas, and JSON streams.

    Pouring my heart and soul into this rewrite has been a journey to make `fx` faster and more powerful. If you find value in what I've crafted and want to support its future, consider sponsoring on GitHub.

    Would love to hear your thoughts and feedback!

  • by parhamn on 9/19/23, 4:20 PM

    > In fx, arguments are treated as JavaScript functions. Input data is passed sequentially through each provided function.

    > echo '{"name": "world"}' | fx 'x => x.name' 'x => `Hello, ${x}!`'

    Wow, that is so nice. Having to memorize JQ syntax is such a pain.

  • by ivanche on 9/19/23, 1:26 PM

    Would've been awesome if results are displayed under the commands. For example, command

      echo '{"name": "hello"}\n{"name": "world"}' | fx '.name'
    
    would output what? My guess is hello world but it might be hello\nworld.
  • by jspeaks on 9/19/23, 1:23 PM

    Having used https://jqlang.github.io/jq/, wondering your pitch on advantages, alternative use cases for using fx?
  • by montroser on 9/19/23, 2:38 PM

    Very cool. Not a huuge deal, but for open source software, I don't totally appreciate the http call to a bitly tracker in the install script...
  • by dpedu on 9/19/23, 5:01 PM

    Pretty cool! I actually wrote something VERY similar a couple of years ago: sless[1]. It's a tool for viewing json-based structured logs. Just like your tool, you can explore into a json object. The difference is, it expects the input to have many json objects, newline separated, and it shows few keys as a preview of the object, to make looking for something in the log easier. It's not quite complete but basic browsing works. It was mainly written to learn more about Urwid[2], a library similar to Curses.

    1: https://github.com/dpedu2/sless

    2: https://urwid.org/

  • by nathell on 9/19/23, 1:44 PM

    The other day, I found myself in need of visualising a tree of paths, like this:

      /one/two
      /one/three/four
      /one/three/five
      /six
    
    I ended up converting it to a JSON with a one-off Python script, and then using fx for the viewing. It worked very well! Thank you for the tool!

    (Incidentally, I’ve been writing my own viewer [0] to satisfy my original need more straightforwardly, but that’s still in very early stages.)

    [0]: https://github.com/nathell/treeviewer

  • by meatjuice on 9/19/23, 1:51 PM

  • by swah on 9/19/23, 1:08 PM

    Any comparison to jless?
  • by cwaffles on 9/19/23, 5:34 PM

    I find `gron` to be very helpful for generating jq query strings

    https://github.com/tomnomnom/gron

  • by lionkor on 9/19/23, 1:46 PM

    > Built using the Go programming language for efficient performance.

    Do you mean to say "efficiency" or "performance"? I dont see both working like that

  • by madspindel on 9/19/23, 6:03 PM

    FYI: .wtf top domain is blocked in HaGeZi's The World's Most Abused TLDs: https://raw.githubusercontent.com/hagezi/dns-blocklists/main...

    Might wanna change to something else.

  • by Daeraxa on 9/19/23, 11:28 AM

    Need to have a bit more of a play with it but I really like it so far. I mainly see myself using it to pipe into (like from curl or the gh cli).

    One thing that isn't clear to me is how to actually use the themes you can display with fx --themes.

  • by gavanwilhite on 9/19/23, 8:34 PM

    Something that would be extra awesome would be light markdown support inside fields. This would make it useful for reviewing chatbot conversations.
  • by who-shot-jr on 9/19/23, 4:13 PM

    Looks great!

    What is the website https://fx.wtf/ built-in?

  • by fodkodrasz on 9/19/23, 1:38 PM

    it is written in Go. What does it have to do with npx/npm at all? Did I miss something about these tools?
  • by nikolay on 9/19/23, 6:47 PM

    It is nice for PCs, but requiring Node.js limits its use on servers.
  • by replwoacause on 9/19/23, 12:51 PM

    This looks really nice.
  • by tinix on 9/19/23, 9:24 PM

    visidata anyone?
  • by _def on 9/19/23, 7:19 PM

    amazing! Does someone know something like this for yaml? (does not have to be cli)
  • by JohnMakin on 9/19/23, 5:09 PM

    could've used this a few years ago before jq became so second nature, cool