Miller (mlr): Convert CSV, TSV, JSON and Pretty Tables
mlr converts record data between CSV, TSV, JSON and aligned tables by combining input and output format flags.
Miller's format flags are orthogonal: pick an input format and an output format and cat does the conversion. The c2j-style shorthands cover the common pairs.
What it does
mlr reads in the input format (--icsv, --itsv, --ijson) and writes in the output format (--ojson, --ocsv, --opprint). Shorthands like --c2j (CSV to JSON) and --j2c (JSON to CSV) name common conversions. With no verb, use cat.
Common usage
# CSV -> JSON
mlr --c2j cat data.csv
# JSON -> CSV
mlr --j2c cat data.json
# CSV -> aligned table for human reading
mlr --c2p cat data.csv
# explicit pair: TSV in, pretty out
mlr --itsv --opprint cat data.tsvOptions
| Flag | What it does |
|---|---|
| --c2j / --j2c | CSV to JSON / JSON to CSV |
| --c2p / --c2t | CSV to pretty table / CSV to TSV |
| --icsv / --ijson / --itsv | Input format |
| --ocsv / --ojson / --opprint | Output format |
| --jlistwrap | Wrap JSON output in a top-level array |
| cat | Pass records through (the no-op verb) |
In CI
Use mlr to normalize a third-party CSV into JSON for a step that only speaks JSON, or --c2p to render a CSV report as an aligned table in the job log. Because Miller round-trips through typed records, numbers stay numbers in the JSON output rather than becoming quoted strings.
Common errors in CI
Converting nested JSON to CSV that is not rectangular triggers mlr: CSV schema change unless you flatten first; pipe through flatten or use --ojsonl. Forgetting a verb (mlr --c2j data.csv) errors with mlr: verb "data.csv" not found because Miller expects a verb before the filename; insert cat. JSON output is newline-delimited unless you add --jlistwrap, which trips consumers expecting a single array.