# jc: Convert CLI Tool Output to JSON for Scripting and Automation

> jc is a MIT-licensed Python CLI and library that parses the text output of common commands like dig, ps, and ls into structured JSON, YAML, or Python dicts, making those outputs directly pipeable to jq or usable in Ansible, Saltstack, and Nornir without writing custom parsers.

**kellyjonbrazil/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.

- Repository: https://github.com/kellyjonbrazil/jc
- Stars: 8,690 · Forks: 258
- Language: Python
- License: MIT
- Published: 2026-09-21 · Updated: 2026-09-21 · Language: en
- Canonical page: https://hysenlabs.com/projects/kellyjonbrazil-jc

## The Problem jc Solves: Structured Data From Text Pipelines

Most Unix command-line tools output text formatted for human reading: fixed-width columns, headers, custom separators. Extracting one field from that output typically means writing a fragile awk one-liner that breaks when the tool changes its column width or adds a new field. jc solves this by providing a stable JSON layer between a command and the downstream consumer.

The README describes jc as JSONifying the output of many CLI tools and file-types, enabling piping to tools like jq and simplifying automation scripts. Version 1.26.0 was released on 19 September 2026, and the repository received its last push on 23 September 2026, placing the project under active development. It is MIT-licensed, written in Python, and requires Python 3.6 or higher.

## How jc Parsers Work: Strict Schema and Raw Mode

Each supported command or file type has a dedicated parser in jc. Parsers operate in two modes.

The default (strict) mode converts known numeric strings to int or float JSON values, converts known boolean strings to JSON booleans, converts known null representations to JSON null, and in some cases adds extra semantic context fields that did not appear in the original text. The README gives an example where the `dig` output includes an epoch timestamp field derived from the `when` string.

The raw mode returns the pre-processed text without numeric conversion or added context. In CLI use, the `-r` flag enables raw mode. In library use, the `raw=True` parameter on `parse()` enables it. Raw mode is useful when the caller needs the original string values rather than jc's interpreted types.

Schemas for each parser are documented alongside the parser list. The schemas define what fields each parser produces, making it possible to write downstream jq expressions with confidence about what keys are always present.

jc also supports streaming parsers for large inputs. The README describes streaming parsers that return a lazy iterable of dictionaries rather than loading the entire output into memory, which matters for commands that produce thousands of output lines.

## Installing jc on Any Platform

The README provides several installation paths. Via pip, which works on macOS, Linux, and Windows:

```bash
pip3 install jc
```

The three Python dependencies jc requires are listed in requirements.txt: `ruamel.yaml`, `xmltodict`, and `Pygments` (all with minimum version constraints). On Debian or Ubuntu:

```bash
apt-get install jc
```

On Fedora:

```bash
dnf install jc
```

On macOS:

```bash
brew install jc
```

Pre-compiled binaries for each architecture are available from the releases page on GitHub. The README also lists zypper, pacman, nix-env, guix, emerge, and tdnf as available package managers, with FreeBSD covered via the ports tree. The full package availability map is tracked at repology.org/project/jc/versions.

## Pipe Syntax and Magic Syntax

jc supports two usage styles. The explicit pipe style passes the tool's output through stdin and specifies the parser with a double-dash flag:

```bash
dig example.com | jc --dig
```

The output is JSON. The dig JSON can then be piped directly to jq:

```bash
$ dig example.com | jc --dig | jq -r '.[].answer[].data'
93.184.216.34
```

The magic syntax places jc before the command name, removing the need for explicit redirection and the `--parser` flag:

```bash
$ jc dig example.com | jq -r '.[].answer[].data'
93.184.216.34
```

Both produce the same output. The magic syntax is more concise for interactive use. The README notes that the pipe style is the explicit form; the magic form infers the parser from the first argument after `jc`. Both styles are supported in the current version.

A web demo of jc is available at jc-web.onrender.com, and a REST API is available at the project's jc-restapi repository for environments where the CLI cannot be installed.

## Using jc as a Python Library

jc can be imported as a Python package rather than called as a subprocess. The `jc.parse()` function takes the parser name and the command output as a string, and returns a Python dictionary, a list of dictionaries, or a lazy iterable depending on the parser.

From the README:

```python
import subprocess
import jc

cmd_output = subprocess.check_output(['dig', 'example.com'], text=True)
data = jc.parse('dig', cmd_output)

data[0]['answer']
```

The return value `data[0]['answer']` is a Python list of dictionaries with the parsed answer section, no further text manipulation required. The library mode returns Python objects directly; JSON serialisation is not performed, since the caller typically wants native Python structures rather than a string.

The library is typed (`py.typed` is included in the package data), which means IDEs and type checkers can provide completeness feedback for the returned dictionary keys when schemas are available.

For the Ansible filter plugin path, jc is available in the `community.general` collection and can be applied to command output registered in Ansible tasks without installing jc separately on the managed host.

## Automation Integrations: Ansible, Saltstack, and FortiSOAR

jc has documented integration paths for several automation frameworks beyond simple bash scripting.

The Ansible filter plugin is distributed as part of the `community.general` collection, installable with:

```bash
ansible-galaxy collection install community.general
```

This makes jc available as a filter in Ansible playbooks, letting tasks parse registered command output without a separate shell pipe step. The README links to a blog post demonstrating command output parsing in Ansible.

For Saltstack and Nornir, the README links to separate blog posts demonstrating how jc fits into those automation frameworks as a parsing step. The FortiSOAR connector is available through the FortiSOAR Connector Marketplace.

These integrations make jc a reusable parsing layer across different automation systems rather than a tool tied to one workflow. The common thread is command output that arrives as a string and needs to be consumed as structured data downstream.

## Limitations and Alternatives to jc

jc's capability depends entirely on its parser list. If a command or file type does not have a parser, jc cannot help: the tool has no general-purpose text parser that guesses structure from column alignment or delimiters. The README directs users to the parsers section and the release notes for coverage details.

The related searches show users looking at yq, which parses and transforms YAML and JSON files rather than command output. yq operates on structured files that already have known formats; jc targets the unstructured text that commands print to stdout. The two tools address different problems: yq for config file manipulation, jc for command output normalisation.

Dasel is another alternative in the related searches. Dasel is a CLI for reading and writing data structures in JSON, YAML, TOML, CSV, and XML files, using a selector syntax. Like yq, it operates on files with known structure rather than arbitrary command output.

For commands that produce YAML or JSON natively, jc adds nothing over a direct `| jq` pipe. jc's value is specifically for commands whose output is text with no machine-readable format, where writing a bespoke parser for each one in a script is the only alternative.

## Conclusion

Operations engineers who write automation scripts against command-line tools and spend time parsing text output with awk and sed should evaluate jc. It covers a large set of common commands and integrates with Ansible's community.general collection directly. The tool is not the right fit when the target command is not in jc's parser list, since jc cannot infer structure from arbitrary text. The MIT licence allows unrestricted commercial use, and the Python 3.6 minimum means it runs on most current Linux distributions without upgrading the interpreter.

## FAQ

### What does jc do?

jc converts the text output of popular CLI tools, file types, and common strings into JSON, YAML, or Python dictionaries. This lets you pipe command output to jq or use it directly in Python automation scripts without writing a custom text parser.

### How do I install jc?

Install jc with pip3 install jc on any platform, or via native OS packages: apt-get install jc on Debian and Ubuntu, dnf install jc on Fedora, and brew install jc on macOS. Pre-compiled binaries are also available from the GitHub releases page.

### What is the difference between jc pipe syntax and magic syntax?

With pipe syntax, you run the command first and pipe its output to jc with an explicit parser flag: dig example.com | jc --dig. With magic syntax, you place jc before the command and omit the flag: jc dig example.com. Both produce the same JSON output.

## Sources

- [Issues](https://github.com/kellyjonbrazil/jc/issues)
- [kellyjonbrazil/jc on GitHub](https://github.com/kellyjonbrazil/jc)
- [License: MIT](https://github.com/kellyjonbrazil/jc/blob/master/LICENSE)
- [README](https://github.com/kellyjonbrazil/jc/blob/master/README.md)
- [Releases](https://github.com/kellyjonbrazil/jc/releases)

---

Hysen Labs editorial analysis, written from the project's own repository and release notes. Cite the canonical page: https://hysenlabs.com/projects/kellyjonbrazil-jc
