What is the jc command?
If you work on the Linux command line a lot, you probably pipe things to grep, awk, or cut to pull out specific fields. It works, but it is fragile. One column shift and your parsing breaks. The jc command solves this by taking standard command output and converting it to JSON.
JC stands for “JSON Convert.” It is an open source tool written in Python by Kelly Brazil. You pipe the output of a command like ps aux or df -h into jc, and it returns clean structured JSON. No parsing, no regex, no headaches.
I use jc all the time for quick scripts. Instead of writing a 10-line awk block to parse ss -tlnp, I pipe it into jc and get an array of objects I can work with in Python or jq. It saves me time every week.
Installing the jc command on Linux
Installing the jc command is straightforward. It is available in most package managers and also on PyPI.
On Debian and Ubuntu:
sudo apt install jc
On Fedora and RHEL:
sudo dnf install jc
On Arch Linux:
sudo pacman -S jc
If you prefer pipx (which I recommend for Python tools), you can install it that way too:
pipx install jc
On macOS, you can use Homebrew:
brew install jc
Check that it works with a simple test:
date | jc --date
You should see JSON output with the current date parsed into fields like year, month, day, and time. If that works, you are ready to go. The --date parser is one of the simplest, so it is a good starting point.
Run jc -a to see every command jc can parse. The list includes over 100 different parsers at the time of writing. New ones get added regularly.
Basic Usage of the jc command
JC follows a simple pattern. You run a normal Linux command and pipe its output to jc. JC detects which command generated the output and parses it accordingly.
Here is a basic example with df:
df -h | jc --df
Instead of the usual table, you get JSON like this:
[
{
"filesystem": "/dev/sda1",
"size": "100G",
"used": "45G",
"avail": "55G",
"use_percent": "45%",
"mounted_on": "/"
}
]
Each column becomes a named field. You can pipe this directly into jq to filter, sort, or reformat. No more counting column positions. I wrote a full guide to using the jq command if you want to learn how to slice and dice JSON output like this.
Another example with ps:
ps aux | jc --ps
This gives you every process as a JSON object with fields like pid, cpu_percent, mem_percent, rss, and command. It is a lot easier to work with than the raw table if you are building a monitoring script.
5 Practical Examples with the jc command
Let me show you five real scenarios where the jc command makes your life easier.
1. Parse Network Connections
You want to see all listening TCP connections and their PIDs as JSON. Use ss with jc:
ss -tlnp | jc --ss
The output includes local_port, process, and state as separate fields. You can filter with jq to find specific ports or processes.
2. Monitor Disk Usage in Scripts
I have a script that checks disk usage across servers. Instead of parsing df output with awk, I use the jc command:
df -h | jc --df | jq '.[] | select(.use_percent | tonumber > 90) | .filesystem'
This returns only the filesystems above 90% usage. Clean, reliable, and it works across different locale settings.
3. Parse Cron Jobs
Need to audit cron jobs on a system? Pipe crontab output through the jc command:
crontab -l | jc --crontab
You get each cron entry parsed into minute, hour, day_of_month, month, day_of_week, and command. It beats reading raw cron syntax, especially when you have complex schedules.
4. Examine System Services
Checking which services are running with systemctl?
systemctl list-units --type=service | jc --systemctl
The JSON output gives you unit, load, active, sub, and description as clean fields. You can write a script that checks if critical services are active without writing fragile parsers.
5. Parse Timestamp Data
The date command output varies by locale and format. The jc command normalizes it:
date | jc --date
You get structured fields for year, month, day, hour, minute, second, and timezone. This is incredibly useful for log processing and timestamp normalization.
Parsing More Complex Output
Some commands produce output that looks simple but is tricky to parse. JC handles over 100 parsers, including ifconfig, lsblk, lsof, lspci, nmcli, and dig.
You can list all supported parsers with:
jc -a
This shows every command jc can parse. If you work with a specific tool regularly, check if jc supports it. The list grows with every release.
One of my favorite features is the --pretty flag. It formats the JSON output for readability in the terminal, so you can inspect the structure before piping it somewhere else:
ps aux | jc --ps --pretty
Why Use the jc command for Scripting?
There are a few reasons I reach for the jc command instead of writing custom parsers.
First, it is reliable. The parsers are tested against many versions of each command. When something changes in the output format of df or ps, the jc maintainers update the parser. You do not have to chase these changes yourself. The jc package on PyPI gets regular updates with new parsers and bug fixes.
Second, it makes your scripts readable. A script that uses jc and jq is easier to understand than one with awk one-liners and regex patterns. New team members can see what the script does without decoding a 50-character sed command.
Third, it works with pipx and virtual environments, so you can install it alongside other Python tools without polluting your system Python. Check out the pipx tool guide I wrote earlier for more on that workflow.
If you want to go deeper, the jc GitHub repository has the full documentation and a list of every supported parser. The project is actively maintained and new parsers are added based on community requests.
For similar tools that make your command line life easier, have a look at the jq command tutorial and the fd command examples on this site. Both are tools I use alongside jc every day.