jc
CLI tool and python library that converts the output of popular command-line tools, file-types, and common strings to JSON, YAML, or Dictionaries. This allows piping of output to tools like jq and simplifying automation scripts.
A command-line tool and Python library that converts the plain-text output of over a hundred Unix commands into clean, structured JSON you can filter and process programmatically.
jc is a command-line tool and Python library that takes the text output of common Unix/Linux commands and converts it into structured JSON. Many standard tools like dig, ping, ls, ps, ifconfig, netstat, and dozens of others print their results as plain text designed for human reading, not machine processing. jc acts as a translator sitting between those commands and anything that needs to process the data programmatically.
The typical usage is to pipe a command's output through jc in a shell pipeline. For example, running a DNS lookup and piping it through jc produces a clean JSON object with all the fields labelled and typed correctly. From there you can pipe it into tools like jq to filter or transform the data. jc also supports a shorthand syntax where you write jc in front of the original command rather than piping through it.
Beyond the command-line tool, jc works as an importable Python library. You pass a string of command output into the parse function along with the name of the parser, and you get back a Python dictionary or list of dictionaries. This is useful when automating tasks with Ansible, SaltStack, or other configuration management tools that run commands and need to inspect the results.
jc ships parsers for well over a hundred different commands and file formats. Each parser has a documented schema so you know exactly what fields to expect in the output. There is also a raw output mode that skips some of the type conversion and returns the data closer to its original form.
The project is available as a Python package installable via pip, through package managers on most major Linux distributions and macOS via Homebrew, and as standalone precompiled binaries. It also appears as an Ansible filter plugin in the community.general collection. The full README is longer than what was shown.
Where it fits
- Parse the output of commands like ping, ps, or ifconfig in a shell script without writing custom text parsers.
- Feed structured command output into Ansible or SaltStack automation tasks that expect typed data.
- Build a monitoring script that runs netstat and processes the results as JSON with jq.
- Import jc as a Python library to programmatically parse command output inside automation tools.