remarshal: Convert TOML, YAML and JSON
remarshal -i config.toml -o config.json converts between TOML, YAML, and JSON while preserving structure.
remarshal round-trips config formats so a tool that only reads JSON can consume your TOML or YAML. In CI it is handy for feeding config into a JSON-only validator.
What it does
remarshal parses an input document (TOML, YAML, JSON, or CBOR) and re-serializes it in the target format, preserving the data structure. It ships convenience commands (toml2json, yaml2json, json2yaml, and so on) that fix the input and output formats.
Common usage
pipx install remarshal
# explicit input/output formats
remarshal --if toml --of json -i pyproject.toml -o out.json
# convenience wrappers
toml2json Cargo.toml
yaml2json values.yaml
json2toml config.json
# convert then validate JSON-only with another tool
yaml2json config.yaml | check-jsonschema --schemafile s.json -Options
| Flag | What it does |
|---|---|
| -i, --input <file> | Input file (default stdin) |
| -o, --output <file> | Output file (default stdout) |
| --if <fmt> | Input format: toml, yaml, json, cbor |
| --of <fmt> | Output format |
| --indent-json <n> | Indent width for JSON output |
| -k, --preserve-key-order | Keep original key ordering where possible |
In CI
Use remarshal as a bridge: convert TOML/YAML to JSON so a JSON-only schema validator (like ajv-cli) can gate it. A conversion failure exits non-zero, so a malformed source file already fails the step before the downstream validator even runs.
Common errors in CI
Error: cannot parse ... as TOML (or YAML/JSON) with a line number means the source is malformed. Error: unknown input format means a bad --if value. Duplicate TOML keys raise a parse error. command not found: remarshal or toml2json means the package is not installed; use pipx or pip. Non-string YAML keys can fail JSON conversion since JSON keys must be strings.