$linuxjunkies
>

fx(1)

A command-line JSON processor that uses JavaScript for querying, filtering, and transforming JSON data interactively.

UbuntuDebianFedoraArch

Synopsis

fx [OPTIONS] [FILE] [FILTER]

Description

fx is a modern JSON processor that provides an interactive terminal UI for exploring and manipulating JSON. It allows you to pipe JSON data and apply JavaScript expressions to transform, filter, or extract specific fields, making it ideal for working with APIs and log files.

Without arguments, fx opens an interactive mode where you can navigate JSON structures and write filtering expressions in real-time. You can also pass a filter expression directly to process JSON non-interactively.

Common options

FlagWhat it does
-r, --raw-outputOutput raw strings instead of JSON-encoded strings
-s, --slurpRead entire input stream into an array and process as a single JSON value
-c, --compactCompact output; print JSON without pretty-printing
--tabUse tabs for indentation instead of spaces
-M, --monochromeDisable color output
-n, --null-inputUse null as input instead of reading from stdin
--jsEnable JavaScript syntax extensions
--yamlOutput results in YAML format

Examples

Fetch JSON from API and open interactive explorer to browse the response

curl https://api.example.com/users | fx

Filter array of user objects and extract names of users over 30 years old

fx '.[] | select(.age > 30) | .name' users.json

Parse JSON, increase all prices by 10%, and sum the total

cat data.json | fx '.data | map(.price * 1.1) | add'

Extract all email addresses from users array and output as comma-separated string

fx -r '.users | map(.email) | join(", ")' data.json

Transform array of objects to extract specific fields and rename one field

fx '.[] | {name, age, status: .active}' users.json

Double array elements and keep only those greater than 4

echo '[1,2,3,4,5]' | fx 'map(x => x * 2) | filter(x => x > 4)'

Related commands