Dev

Best Command-Line JSON Tool: Fx (Interactive & Fast)

I stumbled upon one of the best Command Line JSON processing tools and Viewer, named fx. This tool is written in Node.js and distributed as a single binary without external dependencies. It is designed to give you a nice view and navigation of JSON files.

Original content from computingforgeeks.com - post 17094

Features of fx JSON Viewer

To name a few, here are the core features of fx command line json processing tool.

  • It is easy to use
  • Distributed as standalone binary
  • You operate it in interactive mode
  • Has support for themes to give it a nice look
  • Bash completion support – more productivity
  • Fx has streaming support

Install fx from a standalone binary

The easiest installation method is from a standalone binary. Check the fx downloads page for available releases.

Install wget

# Debian based systems
sudo apt update && sudo apt install wget

# RHEL based systems
sudo yum -y install wget

Get latest release version:

VERSION=$(curl --silent "https://api.github.com/repos/antonmedv/fx/releases/latest" | grep '"tag_name"' | sed -E 's/.*"([^"]+)".*/\1/')

Download binary for Linux that is suitable for your CPU.

# Intel 64-bit
wget https://github.com/antonmedv/fx/releases/download/$VERSION/fx_linux_amd64 -O fx
chmod +x fx && sudo mv fx /usr/local/bin/

# ARM 64-bit
https://github.com/antonmedv/fx/releases/download/$VERSION/fx_linux_arm64 -O fx
chmod +x fx && sudo mv fx /usr/local/bin/

For macOS users, you can use Homebrew or binary.

# Intel
wget https://github.com/antonmedv/fx/releases/download/$VERSION/fx_darwin_amd64 -O fx
chmod +x fx && sudo mv fx /usr/local/bin/

# M1/M2
wget https://github.com/antonmedv/fx/releases/download/$VERSION/fx_darwin_arm64 -O fx
chmod +x fx && sudo mv fx /usr/local/bin

# Homebrew installation
$ brew install fx

Test installation by checking the version:

$ fx --version
35.0.0

Install fx using npm

If you choose to go with npm installation method, install Node.js on your system using our guide below.

  • Install Node.js on Linux / macOS

Thereafter, install fx using below command.

npm install -g fx

Using fx JSON command line viewer

fx can work in two modes: cli and interactive. To start interactive mode pipe into fx any JSON:

$ curl ... | fx

You can also pass file argument as first parameter. fx will apply it and prints to stdout.

fx myfile.json

Click on fields to expand or collapse JSON tree, use mouse wheel to scroll view.

fx read json file

Read fx documentation to learn about all fx operation modes and see more examples which could work for your use case.

Knowledge is the voice you need to break through the IT sphere, this is what will get you started.

Related Articles

Arch Linux Fixing “/usr/bin/pacman: unrecognized option ‘–color never'” on Arch | Manjaro Tips & Tricks Best Ways to Solve the Chicken-and-Egg Problem for a C2C Marketplace CentOS Install Linux Kernel 5.17 on CentOS 8|Rocky Linux 8 Tips & Tricks How can digital adoption help improve the customer experience?

Leave a Comment

Press ESC to close