fx(1)
A command-line JSON processor that uses JavaScript for querying, filtering, and transforming JSON data interactively.
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
| Flag | What it does |
|---|---|
-r, --raw-output | Output raw strings instead of JSON-encoded strings |
-s, --slurp | Read entire input stream into an array and process as a single JSON value |
-c, --compact | Compact output; print JSON without pretty-printing |
--tab | Use tabs for indentation instead of spaces |
-M, --monochrome | Disable color output |
-n, --null-input | Use null as input instead of reading from stdin |
--js | Enable JavaScript syntax extensions |
--yaml | Output results in YAML format |
Examples
Fetch JSON from API and open interactive explorer to browse the response
curl https://api.example.com/users | fxFilter array of user objects and extract names of users over 30 years old
fx '.[] | select(.age > 30) | .name' users.jsonParse 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.jsonTransform array of objects to extract specific fields and rename one field
fx '.[] | {name, age, status: .active}' users.jsonDouble array elements and keep only those greater than 4
echo '[1,2,3,4,5]' | fx 'map(x => x * 2) | filter(x => x > 4)'