Skip to content
Latchkey

remarshal: Convert JSON, YAML, TOML, and MsgPack

remarshal converts a document between JSON, YAML, TOML, and MessagePack, choosing formats with -i and -o or via the yaml2json/json2toml shortcut commands.

When a tool needs JSON but your config is YAML (or a manifest needs TOML), remarshal does the round trip cleanly, preserving types better than ad hoc sed.

What it does

remarshal reads the input format (-i or inferred from the extension), parses it into a common structure, and writes the output format (-o). It ships shortcut binaries like yaml2json, json2yaml, and toml2json that preset the formats.

Common usage

Terminal
remarshal -i yaml -o json config.yaml
yaml2json config.yaml > config.json
# TOML to JSON via shortcut
toml2json Cargo.toml

Options

FlagWhat it does
-i <format>Input format: json, yaml, toml, or msgpack
-o <format>Output format
--indent <n>Indentation width for JSON/YAML output
-k, --stringifyCoerce non-string keys/values where a format requires strings

In CI

remarshal is the reliable bridge when one step emits YAML and the next expects JSON. The shortcut commands (yaml2json, json2yaml) read cleanly in a pipeline. Unlike a naive converter, it round-trips numeric and boolean types, so a true stays a boolean rather than becoming the string "true".

Common errors in CI

A parse failure reports the format and location, e.g. "YAMLError" or "toml: ... expected". Converting YAML that uses features TOML cannot express (like null values) raises an error, since TOML has no null; drop or transform those keys first. Passing the wrong -i produces a decode error before any output.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →