Modern DevOps workflows, automation scripts, and systems monitoring pipelines rely heavily on JSON for data interchange. However, classic Linux system administration utilities—such as ls, ps, df, uptime, netstat, and dig—output unstructured, columnar plain text originally designed for human eyes, not automated parsers. Traditionally, developers were forced to chain fragile combinations of grep, awk, sed, and cut to scrape specific fields. The jc utility changes this paradigm by transparently serialising the output of dozens of common Linux commands into clean, structured JSON.
What Is the jc Command in Linux?
Created by Kelly Brazil, jc (JSON CLI) is a dedicated command-line conversion tool that parses text output from over 100 native Unix tools, system configuration files, and log formats into standard JSON objects or arrays. Instead of writing custom regular expressions whenever an upstream utility tweaks its tabular spacing, you pipe the command directly into jc and immediately filter the result using modern JSON processors such as jq or fx.
Because jc converts numeric values into integers or floats and extracts boolean states automatically, downstream scripts receive properly typed JSON rather than raw text strings.
How to Install jc on Linux
The jc utility is available across major Linux package repositories, Python package managers, and standalone binary distributions.
Method 1: Installing via Native Package Managers
On modern Debian and Ubuntu distributions:
sudo apt update
sudo apt install jc
On Fedora and CentOS Stream:
sudo dnf install jc
On Arch Linux:
sudo pacman -S jc
Method 2: Installing via Pip
If you prefer using Python package management, install jc via pipx or pip:
pipx install jc
Confirm that the utility is installed properly by checking the version:
jc -v
Basic Usage: Piping Commands into jc
To convert command output into JSON, use the -- flag followed by the target command name, or pipe the output directly:
uptime | jc --uptime
This command turns the traditional uptime banner into structured key-value pairs:
{
"time": "14:22:05",
"uptime": "12 days, 4:18",
"users": 2,
"load_1m": 0.15,
"load_5m": 0.22,
"load_15m": 0.18
}
Notice that floating-point load averages and integer user counts are automatically typed rather than left as plain strings.
Magic Syntax: Running Commands Directly with jc
To avoid manually specifying the parser type, jc provides a convenient “magic syntax” that detects and runs commands automatically:
jc ls -la
In this syntax, jc invokes ls -la internally, captures standard output, detects the ls format, and emits the resulting JSON array. You can use magic syntax across numerous everyday diagnostic tools:
jc df -h
jc ps aux
jc ifconfig
jc ip addr
Piping jc Output into jq for Precision Filtering
The true power of jc becomes evident when combined with jq to construct resilient shell pipelines without complex text scraping.
Example 1: Extracting Partition Mounts Exceeding Storage Thresholds
To find all mounted partitions with more than 80% disk usage:
jc df | jq '.[] | select(.use_percent > 80) | {mount: .mounted_on, usage: .use_percent}'
Example 2: Inspecting Memory Consumption of Running Processes
To identify the top three memory-consuming processes and output their PIDs and command names:
jc ps aux | jq 'sort_by(.mem_percent) | reverse | .[0:3] | .[] | {pid: .pid, command: .command, mem: .mem_percent}'
Example 3: Querying Network Ports and Listening Services
To retrieve all TCP ports actively listening for inbound traffic:
jc netstat -tuln | jq '.[] | select(.state == "LISTEN" and .proto == "tcp") | .local_port'
Parsing Configuration Files and Log Outputs
Beyond interactive binary output, jc excels at parsing static system files directly from disk:
cat /etc/passwd | jc --passwd
cat /etc/hosts | jc --hosts
cat /etc/fstab | jc --fstab
This allows configuration management scripts written in Bash, Python, or Ansible to inspect local system definitions without compiling specialised regex parsers.
Formatting Output: Compact and YAML Support
By default, jc formats output with two-space indentation. To emit compact, single-line JSON suitable for high-throughput stream processing, append the -c flag:
jc -c ps aux
If you prefer YAML output for human readability or Kubernetes configuration authoring, combine jc with the -y flag:
jc -y ip route
Frequently Asked Questions
How many Linux commands does jc support?
The utility supports over 100 parsers covering system status tools, networking commands, package managers, and configuration file formats. You can view the complete active parser inventory by running jc -a.
Can jc parse streaming output in real time?
Yes, jc includes streaming parsers for tools like ping, top, and vmstat using the --sl streaming line flag, outputting newline-delimited JSON (NDJSON) as packets arrive.
Does jc modify the original commands or system binaries?
No. The jc binary operates strictly as a user-space text parser and does not alter shell environments or underlying system utilities.