Format examples
nesdit reads and writes JSON, YAML, and TOML. By default the output format equals the input format. Use --output-format to transcode to a different format.
Current limitations
- Comments are not preserved across round-trips. This is an explicit non-goal for v1. If your files contain comments that matter, keep the source-of-truth file elsewhere and generate the deployed copy from it.
- YAML anchors and aliases are resolved on decode and not re-emitted. Output contains the fully expanded values. Merge keys (
<<: *anchor) are applied at decode time — merged fields appear as regular keys in the output map, with explicit keys taking precedence over merged defaults. - JSON output is always compact (single-line, no indentation).
--prettycurrently only affects TOML output. - YAML quoted strings are normalized to bare scalars on output. A value like
"100m"becomes100m. This applies to all keys in the document, not only those touched by the query.
JSON → JSON
Input (config.json):
Identity round-trip (no mutation):
Stdout:
Key order is preserved exactly. The output is byte-identical to the input.
Field mutation:
Stdout:
Field deletion:
Stdout:
YAML → YAML
Input (values.yaml):
Identity round-trip:
Stdout:
Multi-document stream:
Input (stream.yaml):
Stdout:
TOML → TOML
Input (project.toml):
Mutation:
Stdout:
Note
nesdit always emits TOML using inline-table syntax for nested structures. This preserves your key order exactly. Your idiomatic [section] TOML input is read correctly; the output looks like {key = value} for nested tables. This is a deliberate trade-off for round-trip fidelity (see DR-006 in the spec).
JSON → YAML (--output-format=yaml)
Cross-format transcoding: read JSON, write YAML.
Input (input.json):
File mode (no --- prefix for single-document output):
Stdout:
STDIN stream mode (adds --- prefix):
Stdout:
Warning
Running --check on a cross-format invocation with an identity query always exits 2 — even when nothing changed semantically — because the two serializations are never byte-identical:
YAML → JSON (--output-format=json)
Input (input.yaml):
File mode:
Stdout:
Key order is preserved: name precedes version in the input and in the output.
YAML → TOML (--output-format=toml)
Input (input.yaml):
Stdout:
JSON → TOML (--output-format=toml)
Input (input.json):
Stdout:
Multi-document stream → TOML
When the input stream contains more than one document, TOML output documents are separated by +++ (Hugo-style multi-document TOML convention; not part of the TOML specification):
Stdout:
TOML → YAML (--output-format=yaml)
Input (input.toml):
File mode:
Stdout:
--output-format conflict with -i
--output-format and -i are mutually exclusive. Writing a different format back into the same file would silently corrupt it:
nesdit: error: flag.conflict: --output-format and -i are mutually exclusive: --output-format with -i would write a different format into the same file; use a separate output path
Use redirection instead: