Converts the output of popular command-line tools and file-types to JSON.
—
Over 240 specialized parsers for converting output from specific commands, file formats, and data patterns to structured JSON. Each parser follows a consistent interface and includes metadata about compatibility and usage.
All parsers follow the same standard interface pattern:
def parse(
data: str,
quiet: bool = False,
raw: bool = False
) -> Union[Dict[str, Any], List[Dict[str, Any]]]:
"""
Parse command output or file content into structured JSON.
Parameters:
- data: Input string to parse
- quiet: Suppress warning messages if True
- raw: Output preprocessed JSON if True
Returns:
- Dictionary or List of Dictionaries containing parsed data
"""
# Parser metadata object
info: ParserInfoType # Contains parser metadata and compatibility informationParse output from system information and status commands.
Available Parsers:
uname - Parse uname command outputuptime - Parse uptime command outputfree - Parse free command outputdf - Parse df command outputmount - Parse mount command outputlsblk - Parse lsblk command outputdmidecode - Parse dmidecode command outputsysteminfo - Parse Windows systeminfo command outputParse output from network diagnostic and configuration commands.
Available Parsers:
dig - Parse dig DNS lookup outputhost - Parse host DNS lookup outputping - Parse ping command outputnetstat - Parse netstat command outputss - Parse ss socket statistics outputifconfig - Parse ifconfig network interface outputip-address - Parse ip address command outputip-route - Parse ip route command outputarp - Parse arp table outputroute - Parse route table outputParse output from process monitoring and system statistics commands.
Available Parsers:
ps - Parse ps process list outputtop - Parse top command outputiostat - Parse iostat I/O statisticsvmstat - Parse vmstat virtual memory statisticsmpstat - Parse mpstat processor statisticspidstat - Parse pidstat process statisticsw - Parse w logged users outputwho - Parse who logged users outputlast - Parse last login history outputParse file system information and file content.
Available Parsers:
ls - Parse ls directory listing outputfind - Parse find command outputfile - Parse file type identification outputstat - Parse stat file information outputlsattr - Parse lsattr file attributes outputdu - Parse du disk usage outputfstab - Parse /etc/fstab file contenthosts - Parse /etc/hosts file contentParse output from package management commands.
Available Parsers:
apt-cache-show - Parse apt-cache show outputapt-get-sqq - Parse apt-get -sqq outputdpkg-l - Parse dpkg -l package listrpm-qi - Parse rpm -qi package infopip-list - Parse pip list outputpip-show - Parse pip show package detailsParse various configuration file formats.
Available Parsers:
ini - Parse INI configuration filesyaml - Parse YAML filesxml - Parse XML filescsv - Parse CSV filesjson - Parse JSON files (with validation)toml - Parse TOML filesplist - Parse Apple plist filesParse security-related command output and certificate information.
Available Parsers:
x509-cert - Parse X.509 certificate informationx509-csr - Parse X.509 certificate signing requestsgpg - Parse GPG command outputssh-conf - Parse SSH configuration filessshd-conf - Parse SSH daemon configurationReal-time parsers for continuous data processing (append -s to parser name).
Available Streaming Parsers:
ping-s - Stream ping output in real-timesyslog-s - Stream syslog entriesclf-s - Stream Common Log Format entriescsv-s - Stream CSV datatop-s - Stream top command outputHelper functions for building custom parsers:
# From jc.parsers.universal module
def simple_table_parse(data: Iterable[str]) -> List[Dict]:
"""
Parse simple tables with no blank cells.
Parameters:
- data: Text data split into lines, with item 0 as header row
Returns:
- List of dictionaries representing table rows
"""
def sparse_table_parse(data: Iterable[str], delim: str = '\u2063') -> List[Dict]:
"""
Parse tables that may contain blank cells.
Parameters:
- data: Text data split into lines
- delim: Delimiter character for sparse fields
Returns:
- List of dictionaries representing table rows
"""# Method 1: Via main parse function
import jc
data = jc.parse('dig', dig_output)
# Method 2: Via get_parser
jc_dig = jc.get_parser('dig')
data = jc_dig.parse(dig_output)
# Method 3: Direct module import
import jc.parsers.dig
data = jc.parsers.dig.parse(dig_output)import jc
# Parse streaming data
ping_lines = ['PING example.com (93.184.216.34): 56 data bytes',
'64 bytes from 93.184.216.34: icmp_seq=0 ttl=56 time=11.632 ms']
ping_stream = jc.parse('ping-s', ping_lines)
for parsed_line in ping_stream:
if parsed_line.get('time_ms'):
print(f"Response time: {parsed_line['time_ms']} ms")import jc
# Get parser metadata
dig_info = jc.parser_info('dig')
print(f"Description: {dig_info['description']}")
print(f"Compatible: {dig_info['compatible']}")
print(f"Version: {dig_info['version']}")
# Check if parser supports streaming
if dig_info.get('streaming'):
print("Supports streaming")
# Get all parsers supporting a specific tag
all_info = jc.all_parser_info()
slurpable_parsers = [p['name'] for p in all_info if 'slurpable' in p.get('tags', [])]# Example parser structure (for plugin development)
"""jc - JSON Convert my_custom_parser"""
info = {
'name': 'my_custom',
'description': 'Custom parser for my data format',
'author': 'Your Name',
'version': '1.0',
'compatible': ['linux', 'darwin', 'win32'],
'tags': ['command']
}
def parse(data, quiet=False, raw=False):
\"\"\"Parse custom data format\"\"\"
# Parser implementation
return parsed_dataInstall with Tessl CLI
npx tessl i tessl/pypi-jc