Quickstart
This guide takes you from zero to a working nesdit edit in under 5 minutes. It uses only JSON and YAML — the two most common formats. No prior knowledge of other formats is needed.
1. Install nesdit
See Installation for other options.
2. Edit a JSON file to stdout
Create a sample file:
Print the file with .env changed to "production":
Expected output:
The file on disk is not changed. nesdit printed the result to stdout.
3. Edit a file in-place
To write the change back to disk, add -i:
The write is atomic (temp file + rename), so the file is never left in a partial state. Verify:
Expected output:
4. Preview changes with --dry-run
Before committing an edit, preview the diff:
Expected output (unified diff):
--- app.json
+++ app.json
@@ -1 +1 @@
-{"env":"production","replicas":1}
+{"env":"production","replicas":3}
The file is not written. --dry-run (or -n) always exits 0 even when the diff is non-empty.
5. Check for drift with --check
--check tests whether a query would change the file, without writing anything:
Expected: exits 0, no output.
Expected: exits 2, no output.
Tip
Exit code 2 means "the file would change." Exit code 1 means an error (parse failure, bad flag, etc.). Use --check in pre-commit hooks and CI to gate on config drift.
6. Edit a YAML file
The same flags work for YAML:
Verify:
Expected output:
What's next
- Modes — all run modes in detail: in-place, stdout, STDIN stream, dry-run, check, and expression builder.
- Format examples — all six format round-trip combinations including cross-format transcoding with
--output-format. - Expression examples —
--arg,--argjson,--from-file,--where, and more. - Pipeline patterns — glob batches, CI steps, pre-commit hooks.
- Reference — all flags.