Polyconv

CLI

Convert, format, and minify structured data from the terminal.

The polyconv CLI accepts files or stdin, infers JSON and TOML from filenames, and writes to stdout unless an output path is provided.

Install

pnpm add -g @polyconv/cli

Convert

polyconv convert <input> [options]

Options:

OptionDescription
-f, --from <format>Source format: json or toml. Required for stdin.
-t, --to <format>Target format. Required.
-o, --output <file>Output file path. Defaults to stdout.
-p, --prettyPretty print supported outputs such as XML and YAML.
-i, --indent <number>Indentation size for supported formatted outputs.
--root-name <name>Root element name for XML.
--sort-keysSort object keys alphabetically.

Target formats: json, xml, yaml, yml, toml, csv, tsv, ini, env, markdown, html, and query.

Examples

polyconv convert data.json --to csv --output data.csv
polyconv convert data.json --to markdown --sort-keys
polyconv convert data.json --to xml --root-name users --pretty --indent 4
polyconv convert config.toml --to json --output config.json

Stdin And Stdout

cat data.json | polyconv convert - --from json --to yaml
cat config.toml | polyconv convert - --from toml --to json
curl https://api.example.com/data.json | polyconv convert - --from json --to yaml | less

Format JSON

polyconv format input.json --indent 2 --sort-keys --output formatted.json
cat input.json | polyconv format - --sort-keys

Minify JSON

polyconv minify input.json --output minified.json
cat large.json | polyconv minify - > small.json

Exit Codes

CodeMeaning
0Success
1Error, including conversion failure or invalid input

On this page