jc(1)
๐ธ NAME ๐ธ
Bestie, meet jc(1), aka JSON Convert โ the icon that JSONifies the output of many CLI tools, file-types, and strings. ๐ซถ
โจ SYNOPSIS โจ
Standard syntax:
COMMAND | jc [SLICE] [OPTIONS] PARSER
cat FILE | jc [SLICE] [OPTIONS] PARSER
echo STRING | jc [SLICE] [OPTIONS] PARSER
Magic syntax:
jc [SLICE] [OPTIONS] COMMAND
jc [SLICE] [OPTIONS] /proc/<path-to-procfile>
๐ DESCRIPTION ๐
Okay so jc JSONifies the output of many CLI tools, file-types, and common strings so your scripts can parse it way easier. It accepts piped input from STDIN and outputs a JSON representation of the previous command's output to STDOUT. ๐ฆ
You can also use the "Magic" syntax by prepending jc to the command you want converted. Options can be passed to jc immediately before the command is given. โจ
Note: "Magic" syntax does not support shell builtins or command aliases. ๐
๐ OPTIONS ๐
๐ง Parsers ๐ง
--acpiโ theacpicommand parser โจ--airportโ theairport -Icommand parser โ๏ธ--airport-sโ theairport -scommand parser โ๏ธ--amixerโ theamixercommand parser ๐๏ธ--apachectlโ theapachectl -Scommand parser ๐ชถ--apt-cache-showโ theapt-cache showcommand parser ๐ฆ--apt-get-sqqโ theapt-get -sqqcommand parser ๐ฆ--arpโ thearpcommand parser ๐ธ๏ธ--asciitableโ the ASCII and Unicode table parser ๐--asciitable-mโ the multi-line ASCII and Unicode table parser ๐--authorized-keysโ the~/.ssh/authorized_keysfile parser ๐--blkidโ theblkidcommand parser ๐ฝ--bluetoothctlโ thebluetoothctlcommand parser ๐ฆท--cbtโ thecbt(Google Bigtable) command parser โ๏ธ--cefโ the CEF string parser ๐งต--cef-sโ the CEF string streaming parser ๐--certbotโ thecertbotcommand parser ๐--chageโ thechage --listcommand parser โณ--cksumโ thecksumandsumcommand parser ๐งฎ--clfโ the Common and Combined Log Format file parser ๐--clf-sโ the Common and Combined Log Format file streaming parser ๐--conntrackโ theconntrackcommand parser ๐--crontabโ thecrontabcommand and file parser ๐ฐ๏ธ--crontab-uโ thecrontabfile parser with user support ๐ค--csvโ the CSV file parser ๐งพ--csv-ihโ the CSV implicit header file parser ๐งพ--csv-sโ the CSV file streaming parser ๐--csv-ih-sโ the CSV implicit header file streaming parser ๐--curl-headโ thecurl --headcommand parser ๐--dateโ thedatecommand parser ๐--datetime-isoโ the ISO 8601 Datetime string parser ๐ฐ๏ธ--debconf-showโ thedebconf-showcommand parser ๐ง--dfโ thedfcommand parser ๐พ--digโ thedigcommand parser ๐--dirโ thedircommand parser ๐--dmidecodeโ thedmidecodecommand parser ๐งฌ--dpkg-lโ thedpkg -lcommand parser ๐ฆ--duโ theducommand parser ๐--efibootmgrโ theefibootmgrcommand parser ๐ฅพ--email-addressโ the Email Address string parser ๐ง--envโ theenvcommand parser ๐ฑ--ethtoolโ theethtoolcommand parser ๐ฐ๏ธ--fileโ thefilecommand parser ๐--findโ thefindcommand parser ๐ญ--findmntโ thefindmntcommand parser ๐ป--fingerโ thefingercommand parser ๐--freeโ thefreecommand parser ๐--fstabโ the/etc/fstabfile parser ๐๏ธ--getfaclโ thegetfaclcommand parser ๐--git-diffโ thegit diff --name-statuscommand parser ๐งโ๐ป--git-logโ thegit logcommand parser ๐--git-log-sโ thegit logcommand streaming parser ๐--git-ls-remoteโ thegit ls-remotecommand parser ๐--gpgโ thegpg --with-colonscommand parser ๐--groupโ the/etc/groupfile parser ๐ฅ--gshadowโ the/etc/gshadowfile parser ๐ถ๏ธ--hashโ thehashcommand parser #๏ธโฃ--hashsumโ the hashsum command parser (md5sum,shasum, etc.) ๐งฎ--hciconfigโ thehciconfigcommand parser ๐ฆท--historyโ thehistorycommand parser ๐ฐ๏ธ--hostโ thehostcommand parser ๐--hostsโ the/etc/hostsfile parser ๐--http-headersโ the HTTP headers parser ๐จ--icsโ theicsfile parser ๐--idโ theidcommand parser ๐--ifconfigโ theifconfigcommand parser ๐--iftopโ theiftopcommand parser ๐--iniโ the INI file parser ๐๏ธ--ini-dupโ the INI with duplicate key file parser ๐๏ธ--iostatโ theiostatcommand parser ๐--iostat-sโ theiostatcommand streaming parser ๐--ip-addressโ the IPv4 and IPv6 Address string parser ๐--ipconfigโ theipconfigWindows command parser ๐ช--iptablesโ theiptablescommand parser ๐ฅ--ip-routeโ theip routecommand parser ๐ฃ๏ธ--iw-scanโ theiw dev [device] scancommand parser ๐ก--iwconfigโ theiwconfigcommand parser ๐ก--jar-manifestโ the Java MANIFEST.MF file parser โ--jobsโ thejobscommand parser ๐งโ๐ผ--jwtโ the JWT string parser ๐ช--kvโ the Key/Value file and string parser ๐๏ธ--kv-dupโ the Key/Value with duplicate key file and string parser ๐๏ธ--lastโ thelastandlastbcommand parser ๐ฐ๏ธ--lddโ thelddcommand parser ๐งฉ--lsโ thelscommand parser ๐--ls-sโ thelscommand streaming parser ๐--lsattrโ thelsattrcommand parser ๐ท๏ธ--lsb-releaseโ thelsb_releasecommand parser ๐ง--lsblkโ thelsblkcommand parser ๐ฝ--lsmodโ thelsmodcommand parser ๐งฉ--lsofโ thelsofcommand parser ๐--lspciโ thelspci -mmvcommand parser ๐ฅ๏ธ--lsusbโ thelsusbcommand parser ๐--m3uโ the M3U and M3U8 file parser ๐ต--mdadmโ themdadmcommand parser ๐พ--mountโ themountcommand parser ๐ป--mpstatโ thempstatcommand parser ๐--mpstat-sโ thempstatcommand streaming parser ๐--needrestartโ theneedrestart -bcommand parser ๐--netrcโ the.netrcfile parser ๐ธ๏ธ--netstatโ thenetstatcommand parser ๐--net-localgroupโ thenet localgroupcommand parser ๐ช--net-userโ thenet usercommand parser ๐ช--nfsiostatโ thenfsiostatcommand parser ๐--nfsiostat-sโ thenfsiostatcommand streaming parser ๐--nftablesโ thenftcommand parser ๐ฅ--nmcliโ thenmclicommand parser ๐ถ--nsd-controlโ thensd-controlcommand parser ๐ฐ๏ธ--ntpqโ thentpq -pcommand parser ๐ฐ๏ธ--openvpnโ theopenvpn-status.logfile parser ๐ก๏ธ--os-proberโ theos-probercommand parser ๐ง--os-releaseโ the/etc/os-releasefile parser ๐ง--pacmanโ thepacmancommand parser ๐ฆ--passwdโ the/etc/passwdfile parser ๐--pathโ the POSIX path string parser ๐ค๏ธ--path-listโ the POSIX path list string parser ๐ค๏ธ--pci-idsโ thepci.idsfile parser ๐ฅ๏ธ--pgpassโ the PostgreSQL password file parser ๐--pidstatโ thepidstat -Hcommand parser ๐--pidstat-sโ thepidstat -Hcommand streaming parser ๐--pingโ thepingandping6command parser ๐ก--ping-sโ thepingandping6command streaming parser ๐--pip-listโ thepip listcommand parser ๐--pip-showโ thepip showcommand parser ๐--pkg-index-apkโ the Alpine Linux Package Index file parser ๐๏ธ--pkg-index-debโ the Debian Package Index file parser ๐--plistโ the PLIST file parser ๐--postconfโ thepostconf -Mcommand parser ๐ฌ--procโ the/proc/file parser ๐๏ธ--proc-buddyinfoโ the/proc/buddyinfofile parser ๐ง--proc-cmdlineโ the/proc/cmdlinefile parser โจ๏ธ--proc-consolesโ the/proc/consolesfile parser ๐ฅ๏ธ--proc-cpuinfoโ the/proc/cpuinfofile parser ๐ง--proc-cryptoโ the/proc/cryptofile parser ๐--proc-devicesโ the/proc/devicesfile parser ๐งฉ--proc-diskstatsโ the/proc/diskstatsfile parser ๐--proc-filesystemsโ the/proc/filesystemsfile parser ๐๏ธ--proc-interruptsโ the/proc/interruptsfile parser โก--proc-iomemโ the/proc/iomemfile parser ๐ง--proc-ioportsโ the/proc/ioportsfile parser ๐--proc-loadavgโ the/proc/loadavgfile parser โ๏ธ--proc-locksโ the/proc/locksfile parser ๐--proc-meminfoโ the/proc/meminfofile parser ๐ง--proc-modulesโ the/proc/modulesfile parser ๐งฉ--proc-mtrrโ the/proc/mtrrfile parser ๐ง--proc-pagetypeinfoโ the/proc/pagetypeinfofile parser ๐--proc-partitionsโ the/proc/partitionsfile parser ๐ฝ--proc-slabinfoโ the/proc/slabinfofile parser ๐งฑ--proc-softirqsโ the/proc/softirqsfile parser โก--proc-statโ the/proc/statfile parser ๐--proc-swapsโ the/proc/swapsfile parser ๐--proc-uptimeโ the/proc/uptimefile parser โฑ๏ธ--proc-versionโ the/proc/versionfile parser ๐ท๏ธ--proc-vmallocinfoโ the/proc/vmallocinfofile parser ๐ง--proc-vmstatโ the/proc/vmstatfile parser ๐--proc-zoneinfoโ/proc/zoneinfofile parser โ the zone info one, parsed and cute ๐ซถ--proc-driver-rtcโ/proc/driver/rtcfile parser โ real-time clock content, iconically converted โฐ--proc-net-arpโ/proc/net/arpfile parser โ that ARP table glow โจ--proc-net-devโ/proc/net/devfile parser โ interface stats, served fresh--proc-net-dev-mcastโ/proc/net/dev_mcastfile parser โ multicast, bestie ๐ฆ--proc-net-if-inet6โ/proc/net/if_inet6file parser โ IPv6 interfaces, slay--proc-net-igmpโ/proc/net/igmpfile parser โ IGMP but make it structured ๐--proc-net-igmp6โ/proc/net/igmp6file parser โ the v6 sibling, equally iconic--proc-net-ipv6-routeโ/proc/net/ipv6_routefile parser โ routing table, but v6 ๐--proc-net-netlinkโ/proc/net/netlinkfile parser โ netlink sockets, no cap--proc-net-netstatโ/proc/net/netstatfile parser โ netstat stats, parsed ๐--proc-net-packetโ/proc/net/packetfile parser โ packet sockets, gorgeous--proc-net-protocolsโ/proc/net/protocolsfile parser โ every protocol, listed--proc-net-routeโ/proc/net/routefile parser โ the classic route table, main character energy ๐--proc-net-tcpโ parses/proc/net/tcpand/proc/net/tcp6, both of them, together, we love a combo ๐--proc-net-udpโ same deal for/proc/net/udpand/proc/net/udp6๐ซถ--proc-net-unixโ/proc/net/unixfile parser โ unix sockets, periodt--proc-pid-fdinfoโ/proc/<pid>/fdinfo/<fd>file parser โ yep, that exact path, with the<pid>and the<fd>๐ง--proc-pid-ioโ/proc/<pid>/iofile parser โ per-process I/O, obsessed--proc-pid-mapsโ/proc/<pid>/mapsfile parser โ memory maps, structured--proc-pid-mountinfoโ/proc/<pid>/mountinfofile parser โ mount info, immaculate--proc-pid-numa-mapsโ/proc/<pid>/numa_mapsfile parser โ NUMA maps, as one does--proc-pid-smapsโ/proc/<pid>/smapsfile parser โ the detailed one, ate--proc-pid-statโ/proc/<pid>/statfile parser โ process stats, lowkey essential--proc-pid-statmโ/proc/<pid>/statmfile parser โ the short one, highkey handy--proc-pid-statusโ/proc/<pid>/statusfile parser โ status, but readable ๐ธ--psโpscommand parser โ your process list, but JSON/YAML ๐--resolve-confโ/etc/resolve.conffile parser โ yes, that path exactly ๐--routeโroutecommand parser โ classic route output, parsed--route-printโroute printcommand parser โ the Windows flavour ๐ช--rpm-qiโrpm -qicommand parser โ package info, served ๐--rsyncโrsynccommand parser โ sync output, structured--rsync-sโrsyncstreaming parser โ for when it's coming at you live ๐--semverโ Semantic Version string parser โ versions, parsed, slay--sfdiskโsfdiskcommand parser โ partition table vibes--shadowโ/etc/shadowfile parser โ handle with care bestie ๐--srtโ SRT file parser โ subtitles, converted โญ--ssโsscommand parser โ socket stats, iconic--ssh-confโsshconfig file andssh -Gcommand parser โ both, together ๐ซถ--sshd-confโsshdconfig file andsshd -Tcommand parser โ same energy, daemon edition--statโstatcommand parser โ file stats, parsed--stat-sโstatstreaming parser โ live and direct ๐ก--swaponโswaponcommand parser โ swap info, gorgeous--sysctlโsysctlcommand parser โ kernel params, structured--syslogโ Syslog RFC 5424 string parser โ yes, RFC 5424 specifically ๐--syslog-sโ Syslog RFC 5424 string streaming parser โ 5424, streaming ๐--syslog-bsdโ Syslog RFC 3164 string parser โ the BSD one, 3164, don't mix them up ๐--syslog-bsd-sโ Syslog RFC 3164 string streaming parser โ 3164 + streaming--systemctlโsystemctlcommand parser โ unit output, parsed--systemctl-ljโsystemctl list-jobscommand parser โ jobs, listed and parsed--systemctl-lsโsystemctl list-socketscommand parser โ sockets, same deal--systemctl-lufโsystemctl list-unit-filescommand parser โ unit files, immaculate--systeminfoโsysteminfocommand parser โ the Windows system info one ๐ช--timeโ/usr/bin/timecommand parser โ that exact binary path, timed โฑ๏ธ--timedatectlโtimedatectl statuscommand parser โ time + date, parsed--timestampโ Unix Epoch Timestamp string parser โ epochs, converted ๐ฅ--tomlโ TOML file parser โ TOML girlies rise ๐--topโtop -bcommand parser โ batch mode top, parsed--top-sโtop -bcommand streaming parser โ batch mode, live ๐--tracepathโtracepathandtracepath6command parser โ both of them ๐ฐ๏ธ--tracerouteโtracerouteandtraceroute6command parser โ both, again ๐ซถ--traceroute-sโtracerouteandtraceroute6command streaming parser โ both, streaming--tsvโ TSV file parser โ tabs, parsed--tsv-ihโ TSV implicit header file parser โ no header row, we figure it out ๐--tsv-sโ TSV file streaming parser โ tabs, streaming--tsv-ih-sโ TSV implicit header file streaming parser โ all four modifiers at once, she's everything ๐--tune2fsโtune2fs -lcommand parser โ that listing flag specifically--typesetโtypesetanddeclarecommand parser โ both shell builtins ๐--udevadmโudevadm infocommand parser โ device info, parsed--ufwโufw statuscommand parser โ firewall status, structured ๐ฅ--ufw-appinfoโufw app info [application]command parser โ note the[application]placeholder, it's a real arg ๐ซถ--unameโuname -acommand parser โ the-a, all of it--update-alt-gsโupdate-alternatives --get-selectionscommand parser โ long flag, exact--update-alt-qโupdate-alternatives --querycommand parser โ the query one--upowerโupowercommand parser โ power info, parsed ๐--upscโupsccommand parser โ UPS status, served--uptimeโuptimecommand parser โ uptime, but structured--urlโ URL string parser โ links, parsed ๐--verโ Version string parser โ plain version strings--veracryptโveracryptcommand parser โ encrypted volume vibes ๐--vmstatโvmstatcommand parser โ virtual memory stats, parsed--vmstat-sโvmstatcommand streaming parser โ stats in real time ๐--wโwcommand parser โ who's doing what, parsed--wcโwccommand parser โ counts, counted โจ--wg-showโwg showcommand parser โ WireGuard, shown and parsed ๐--whoโwhocommand parser โ logged-in humans, listed--x509-certโ X.509 PEM and DER certificate file parser โ both formats, we don't play ๐--x509-crlโ X.509 PEM and DER certificate revocation list file parser โ CRL, both formats--x509-csrโ X.509 PEM and DER certificate request file parser โ CSR, both formats--xmlโ XML file parser โ XML, parsed, sorry about the angle brackets ๐ญ--xrandrโxrandrcommand parser โ display config, structured ๐ฅ๏ธ--yamlโ YAML file parser โ YAML in, YAML out, the circle of life ๐--zipinfoโzipinfocommand parser โ zip contents, parsed--zpool-iostatโzpool iostatcommand parser โ ZFS I/O stats, iconic--zpool-statusโzpool statuscommand parser โ pool status, parsed ๐
โจ Options: โจ
okay so these are the general flags โ the ones that work with everything, the utility players, the ones you'll actually type ๐ซถ
-a,--aboutโ all about jc, delivered as JSON or YAML, your pick ๐-C,--force-colorโ force color output even when you're piping it, and yes it overrides-mand theNO_COLORenv variable. powerful ๐-d,--debugโ debug mode, shows you the traceback; use-ddif you want the verbose traceback, go off ๐-h,--helpโ help! and--help --parser_namegets you that specific parser's docs. Use it twice for hidden parsers (e.g.-hh). Use it thrice for parser categories (e.g.-hhh) โ yes, three h's, she contains multitudes ๐-m,--monochromeโ monochrome output, no color, calm vibes-M,--meta-outโ adds metadata to the output โ timestamp, parser name, magic command, magic command exit code, etc. the receipts bestie ๐งพ-p,--prettyโ pretty print the output, make it look good โจ-q,--quietโ quiet mode, suppresses parser warning messages. Use-qqto also ignore streaming parser errors ๐คซ-r,--rawโ raw output, more literal โ typically string values and no extra semantic processing ๐ชต-s,--slurpโ slurp multiple lines into an array. use-hhhto find the parsers that support it ๐ฅค-u,--unbufferโ unbuffer the output, super useful for slow streaming data with streaming parsers ๐-v,--versionโ version info, that's it, that's the flag ๐ท๏ธ-y,--yaml-outโ YAML output instead of JSON ๐-B,--bash-compโ generate the Bash shell completion script ๐-Z,--zsh-compโ generate the Zsh shell completion script ๐-X,--xonsh-compโ generate the Xonsh shell completion script ๐
โจ Slice: โจ
Line slicing is supported using the START:STOP syntax โ literally the same vibe as Python slicing ๐ and it's so handy. It lets you skip lines at the beginning and/or the end of the STDIN input you want jc to convert ๐
START and STOP can be positive or negative integers, or blank, and they tell jc how many lines to skip and how many lines to process. Positive and blank slices are the most memory efficient. Any negative integers in the slice will use more memory. Lines are counted at LF and CRLF line endings โ a lone CR does not start a new line. important!! ๐ซถ
For example, to skip the first and last line of the following text, you could express the slice in a couple of ways:
$ cat table.txt
### We want to skip this header ###
col1 col2
foo 1
bar 2
### We want to skip this footer ###
$ cat table.txt | jc 1:-1 --asciitable
[{"col1":"foo","col2":"1"},{"col1":"bar","col2":"2"}]
$ cat table.txt | jc 1:4 --asciitable
[{"col1":"foo","col2":"1"},{"col1":"bar","col2":"2"}]
In this example 1:-1 and 1:4 line slices provide the same output. two paths, one slay ๐
When using positive integers the index location of STOP is non-inclusive. Positive slices count from the first line of the input toward the end, starting at 0 as the first line. Negative slices count from the last line toward the beginning, starting at -1 as the last line. This is also exactly the way Python's slicing feature works ๐โจ
Here's the breakdown of line slice options:
START:STOPโ linesSTARTthroughSTOP- 1START:โ linesSTARTthrough the rest of the output:STOPโ lines from the beginning throughSTOP- 1-START:STOPโSTARTlines from the end throughSTOP- 1START:-STOPโ linesSTARTthroughSTOPlines from the end-START:-STOPโSTARTlines from the end throughSTOPlines from the end-START:โSTARTlines from the end through the rest of the output:-STOPโ lines from the beginning throughSTOPlines from the end:โ all lines ๐
okay so like โ some parsers are just built different and can take multi-item input and spit out an array of results in one single pass. Slurping is that for string parsers that accept a single line of input (e.g. url and ip-address). Wanna know which parsers vibe with the --slurp option? Run jc -hhh and it'll list 'em all, no cap.
So for example you can send a file with multiple IP addresses (one per line) to jc with the --slurp option and out comes an array of results:
$ cat ip-addresses.txt | jc --slurp --ip-address
[<multiple output objects>]
The magic syntax for /proc files? It automatically supports slurping of multiple files โ no need to use the --slurp option at all, she's got it handled. So you can convert a whole bunch of PID files at once, like:
$ jc /proc/*/status
[<multiple output objects>]
When the /proc magic syntax is used and multiple files are selected, an additional _file field gets inserted into the output so it's easier to tell what file each output object refers to. genuinely so helpful of her ๐
And finally, the --meta-out option can be used together with slurped output. When you do that, the slurped output gets wrapped in an object with this exact structure:
{
"result": [<multiple output objects>],
"_jc_meta": {
"parser": "url",
"timestamp": 1706235558.654576,
"slice_start": null,
"slice_end": null,
"input_list": [
"http://www.google.com",
"https://www.apple.com",
"https://www.microsoft.com"
]
}
}
With --meta-out, input_list contains a list of inputs (actual input strings or /proc filenames) so you can identify which output object relates to each input string or /proc filename. iykyk ๐ซถ
๐ EXIT CODES ๐
Any fatal errors within jc will generate an exit code of 100. Otherwise the exit code will be 0. Simple as that bestie.
When you're using the "magic" syntax (e.g. jc ifconfig eth0), jc will store the exit code of the program being parsed and add it to the jc exit code. That way it's way easier to figure out whether an error came from the parsed program or from jc herself.
Consider these examples using ifconfig:
ifconfig exit code = 0, jc exit code = 0, combined exit code = 0
(no errors)
ifconfig exit code = 1, jc exit code = 0, combined exit code = 1
(error in ifconfig)
ifconfig exit code = 0, jc exit code = 100, combined exit code = 100
(error in jc)
ifconfig exit code = 1, jc exit code = 100, combined exit code = 101
(error in both ifconfig and jc)
When using the "magic" syntax you can also retrieve the exit code of the called program by using the --meta-out or -M option. That appends a _jc_meta object to the output which includes the magic command information, including the exit code. โจ
Here's an example with ping:
$ jc --meta-out -p ping -c2 192.168.1.252
{
"destination_ip": "192.168.1.252",
"data_bytes": 56,
"pattern": null,
"destination": "192.168.1.252",
"packets_transmitted": 2,
"packets_received": 0,
"packet_loss_percent": 100.0,
"duplicates": 0,
"responses": [
{
"type": "timeout",
"icmp_seq": 0,
"duplicate": false
}
],
"_jc_meta": {
"parser": "ping",
"timestamp": 1661357115.27949,
"magic_command": [
"ping",
"-c2",
"192.168.1.252"
],
"magic_command_exit": 2
}
}
$ echo $?
2
๐ ENVIRONMENT ๐
Custom Colors
You can specify custom colors via the JC_COLORS environment variable ๐จ The JC_COLORS environment variable takes four comma separated string values in this format:
JC_COLORS=<keyname_color>,<keyword_color>,<number_color>,<string_color>
Where the colors are: black, red, green, yellow, blue, magenta, cyan, gray, brightblack, brightred, brightgreen, brightyellow, brightblue, brightmagenta, brightcyan, white, or default.
For example, to set it to the default colors:
JC_COLORS=blue,brightblack,magenta,green
or
JC_COLORS=default,default,default,default
Disable Color Output
You can set the NO_COLOR environment variable to any value to disable color output in jc ๐ซ๐ Just know that using the -C option to force color output will override both the NO_COLOR environment variable and the -m option. she said what she said.
๐ฆ STREAMING PARSERS ๐ฆ
Most parsers load all of the data from STDIN, parse it, then output the entire JSON document serially. But there are some streaming parsers (e.g. ls-s, ping-s, etc.) that immediately start processing and outputting the data line-by-line as JSON Lines (aka NDJSON) while it's being received from STDIN. This can significantly reduce the amount of memory required to parse large amounts of command output (e.g. ls -lR /) and can sometimes process the data more quickly. Streaming parsers have slightly different behavior than standard parsers, as outlined below ๐
Note: Streaming parsers cannot be used with the "magic" syntax.
Ignoring Errors
You may want to ignore parsing errors when using streaming parsers, since these may be used in long-lived processing pipelines and errors can break the pipe ๐ญ To ignore parsing errors, use the -qq cli option. This adds a _jc_meta object to the JSON output with a success attribute. If success is true, then there were no issues parsing the line. If success is false, then a parsing issue was found and error and line fields will be added to include a short error description and the contents of the unparsable line, respectively:
Successfully parsed line with -qq option:
{
"command_data": "data",
"_jc_meta": {
"success": true
}
}
Unsuccessfully parsed line with -qq option:
{
"_jc_meta": {
"success": false,
"error": "error message",
"line": "original line data"
}
}
Unbuffering Output
Most operating systems will buffer output that is being piped from process to process. The buffer is usually around 4KB. When you're viewing the output in the terminal the OS buffer is not engaged, so output is immediately displayed on the screen. But when piping multiple processes together it may seem as if the output is hanging when the input data is very slow (e.g. ping):
$ ping 1.1.1.1 | jc --ping-s | jq
<slow output>
That's because the OS engages the 4KB buffer between jc and jq in this example ๐ To display the data on the terminal in realtime, you can disable the buffer with the -u (unbuffer) cli option:
$ ping 1.1.1.1 | jc --ping-s -u | jq
{"type":"reply","pattern":null,"timestamp":null,"bytes":"64",...}
{"type":"reply","pattern":null,"timestamp":null,"bytes":"64",...}
etc...
Note: Unbuffered output can be slower for large data streams. just so you know ๐
๐ง PARSER PLUGINS ๐ง
Parser plugins may be placed in a jc/jcparsers folder in your local "App data directory":
- Linux/unix:
$HOME/.local/share/jc/jcparsers - macOS:
$HOME/Library/Application Support/jc/jcparsers - Windows:
$LOCALAPPDATA\jc\jc\jcparsers
Parser plugins are standard python module files ๐ Use the jc/parsers/foo.py or jc/parsers/foo_s.py (streaming) parser as a template and simply place a .py file in the jcparsers subfolder. Any dependencies can be placed in the jc folder above jcparsers and can be imported in the parser code.
Parser plugin filenames must be valid python module names, and therefore must start with a letter and consist entirely of alphanumerics and underscores. Local plugins may override default parsers ๐
Note: The application data directory follows the XDG Base Directory Specification.
๐ธ CAVEATS ๐ธ
Locale
For best results, set the locale environment variables to C or en_US.UTF-8 by modifying the LC_ALL variable:
$ LC_ALL=C date | jc --date
You can also set the locale variables individually:
$ export LANG=C
$ export LC_NUMERIC=C
On some older systems, UTF-8 output will be downgraded to ASCII with \u escape sequences if the C locale does not support UTF-8 encoding. yeah. vintage behaviour ๐ญ
Timezones
Some parsers have calculated epoch timestamp fields added to the output. Unless a timestamp field name has a _utc suffix, it is considered naive (i.e. based on the local timezone of the system the jc parser was run on) ๐ฐ๏ธ
If a UTC timezone can be detected in the text of the command output, the timestamp will be timezone aware and have a _utc suffix on the key name (e.g. epoch_utc). No other timezones are supported for aware timestamps.
Line Endings
jc passes input to the parser without translating line endings, whether it comes from STDIN, a "magic" command, or a /proc file. All line-based parsers split lines at LF and CRLF line endings only, so other characters that can appear inside a value, such as a lone CR, form feed, or Unicode line separator, stay part of that line. Parsers for file formats that can use CR-only line endings (csv, hosts, jar-manifest, and m3u) also accept a lone CR as a line ending.
Streaming parsers split STDIN lines the same way (LF and CRLF only). Bytes in STDIN that are not valid UTF-8 are shown as backslash escapes (e.g. \xff) instead of stopping the parser. she's resilient like that ๐ช
โญ EXAMPLES โญ
Standard Syntax:
$ dig www.google.com | jc -p --dig
$ cat /proc/meminfo | jc --pretty --proc
Magic Syntax:
$ jc --pretty dig www.google.com
$ jc --pretty /proc/meminfo
Line Slicing:
$ cat file.csv | jc :101 --csv # parse first 100 lines
For parser documentation:
$ jc --help --dig
More Help:
$ jc -hh # show hidden parsers
$ jc -hhh # list parsers by category tags
๐ AUTHOR ๐
Kelly Brazil (kellyjonbrazil@gmail.com)
https://github.com/kellyjonbrazil/jc
๐ COPYRIGHT ๐
Copyright (c) 2019-2026 Kelly Brazil
License: MIT License
and that's the whole page bestie, you ate that ๐ mwah ๐ this was jc version 1.26.2, dated 2026-10-29 โ now go parse something gorgeous. periodt. ๐
โจ
๐ฆ where this page comes from
- arch rolling: jc 1.26.2-1 ยท MIT
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms