fx
Terminal JSON viewer with interactive navigation.
Official WebsiteFeatures
InteractiveStreamingJavaScript FunctionsThemes
Installation
Homebrew
brew install fxnpm
npm install -g fxWhy use fx?
fx is a lightweight JSON viewer for the terminal that provides an interactive experience for exploring JSON data. Perfect for debugging APIs, inspecting configuration files, and processing large JSON streams without the overhead of traditional editors.
Interactive Navigation
Navigate JSON structures with arrow keys, expand/collapse nodes, and search through large datasets efficiently.
Streaming Support
Process large JSON files and streams without loading everything into memory. Handles gigabyte-sized datasets.
JavaScript Functions
Apply custom JavaScript filters and transformations to manipulate JSON data directly from the terminal.
Minimal & Fast
Written in Go with no external dependencies. Starts instantly and responds smoothly to user input.
Installation
Installation
# macOS (Homebrew)
brew install fx
# Ubuntu/Debian
curl -sL https://github.com/antonmedv/fx/releases/download/v0.98.1/fx-linux -o fx
chmod +x fx
sudo mv fx /usr/local/bin/
# npm
npm install -g fx
# Cargo
cargo install fx
# Windows
choco install fxBasic Usage
Viewing JSON Files
Viewing JSON
# View a JSON file interactively
fx data.json
# Pipe JSON from another command
curl -s https://api.github.com/users/github | fx
# View stdin
echo '{"name":"John","age":30}' | fx
# Pretty-print without interaction
fx data.json . | catNavigation Controls
| Key | Action |
|---|---|
↓/↑ | Navigate down/up |
←/→ | Collapse/expand node |
/ | Search |
g | Go to line |
q | Quit |
Filtering with JavaScript
Filtering
# Select specific property
curl -s https://api.github.com/users/github | fx .login
# Filter array items
echo '[1,2,3,4,5]' | fx '.[] | select(. > 2)'
# Map transformation
echo '[{"name":"Alice","age":25},{"name":"Bob","age":30}]' | fx '.[] | {name, older: .age + 10}'
# Conditional filtering
curl -s https://api.github.com/repos/github/linguist/issues | fx '.[] | select(.state == "open")'Common Use Cases
API Response Exploration
API Exploration
# Explore GitHub API response
curl -s https://api.github.com/repos/torvalds/linux | fx
# Browse nested data
curl -s https://api.example.com/users | fx '.[0]'
# Extract specific fields from large response
curl -s https://api.github.com/users/google/repos | fx '.[] | {name, stars: .stargazers_count}'Data Transformation
Transformations
# Convert to different format
echo '{"users":[{"id":1,"name":"Alice"},{"id":2,"name":"Bob"}]}' | fx '.users | @csv'
# Extract keys
echo '{"a":1,"b":2,"c":3}' | fx 'keys'
# Count items
echo '[1,2,3,4,5]' | fx 'length'
# Group by field
echo '[{"type":"A","val":1},{"type":"B","val":2},{"type":"A","val":3}]' | fx 'group_by(.type)'Debugging Configuration Files
Config Debugging
# View package.json interactively
fx package.json
# Check Docker config
fx ~/.docker/config.json
# Inspect AWS credentials
fx ~/.aws/credentials.json
# Browse Kubernetes resources
kubectl get nodes -o json | fxAdvanced Features
Streaming Large Files
Streaming
# Process JSONL (newline-delimited JSON)
cat events.jsonl | fx '.ip' --null-input
# Stream large JSON array
fx large-data.json '.[100:110]'
# Filter while streaming
fx huge-file.json '.[] | select(.status == "active")'Complex Queries
Complex Queries
# Multiple transformations
echo '[{"name":"Alice","scores":[85,90,88]},{"name":"Bob","scores":[75,80,82]}]' | fx '.[] | {name, avg: (.scores | add / length)}'
# Recursive descent
fx package.json '.. | objects | select(has("version")) | .version'
# Conditional object construction
echo '{"users":[{"id":1,"active":true},{"id":2,"active":false}]}' | fx '.users | map(if .active then {id, status: "active"} else empty end)'Interactive Editing
Editing
# Edit JSON interactively in fx
fx config.json
# Use keyboard shortcuts in fx UI
# Press 'e' to edit current value
# Press 's' to save to file
# Combine with other tools
fx data.json | xargs curl -X POST -dCommon Options
| Option | Description | Example |
|---|---|---|
-r, --raw-output | Output raw strings without quotes | fx data.json -r '.name' |
-c, --compact | Compact output (no pretty-print) | fx data.json -c |
-s, --slurp | Read entire input into array | fx -s '*.json' |
-M, --monochrome | Disable syntax highlighting | fx data.json -M |
--null-input | Use null as input | fx --null-input '1 + 1' |
Tips
- •Use
fxwithout arguments to read from stdin. Great for exploring API responses:curl ... | fx - •The interactive viewer shows line numbers, making it easier to locate deeply nested values
- •Unlike
jq, fx expressions are standard JavaScript, familiar to most developers - •Combine with
xargsfor additional processing:fx file.json '.urls[]' | xargs curl - •Use
-cflag for piping output to other tools when you need compact JSON