Skip to content

Using fx as a TUI for JSON Data ​

If you're working with JSON in the terminal, fx provides a lightweight TUI (Text User Interface) for viewing and exploring structured data interactively.

Why Use a JSON TUI? ​

When debugging APIs, logs, or config files, pretty-printing is often not enough. A TUI lets you navigate deeply nested JSON, expand/collapse sections, and quickly find what you need — without leaving the terminal.

Launching the TUI ​

bash
cat data.json | fx

Or pipe directly from a command:

bash
curl https://api.example.com/data | fx

This opens a fullscreen TUI where you can:

  • Use arrow keys to expand/collapse objects
  • View arrays and nested structures interactively

Features ​

  • Keyboard-driven — ideal for terminal workflows.
  • Streaming support — works with cat, curl, docker, etc.
  • Custom queries — drill into .field.subfield directly or define JavaScript logic.

Example: Explore Docker Metadata ​

bash
docker inspect $(docker ps -q) | fx

Opens metadata of all running containers in the TUI. Press / to search, e.g. for IPAddress.

To print a summary instead of opening the TUI, pass an expression — here, containers grouped by image:

bash
docker inspect $(docker ps -q) | fx 'groupBy(x => x.Config.Image)'

Output:

json
{
  "nginx:1.25": [
    {
      "Id": "abc",
      "Config": {
        "Image": "nginx:1.25"
      }
    }
  ]
}

Summary ​

fx turns JSON into an interactive TUI experience — fast, intuitive, and scriptable. Perfect for developers working in CLI environments who want more than just pretty-printing.