dasel put: Modify JSON and YAML In Place
dasel put writes a value into a structured document at a selector path, editing config files without a templating engine.
Bumping an image tag or toggling a flag in YAML usually means sed hacks. dasel put does it structurally, so quoting and indentation stay valid.
What it does
dasel put updates the node at a selector to a new value, inferring the type or taking it from -t. With -f file ... -o file (or the v2 in-place behaviour) it writes the change back. dasel delete removes a node.
Common usage
# set a string value in place (dasel v2)
dasel put -f deploy.yaml -t string -v "v1.4.2" '.spec.image'
# set an int and write to a new file
dasel put -f config.json -t int -v 8080 -o out.json '.server.port'
# delete a key
dasel delete -f config.yaml '.debug'Options
| Flag | What it does |
|---|---|
| -v, --value <val> | Value to write |
| -t, --type <type> | Value type: string, int, bool, float, json |
| -f, --file <path> | File to edit (in place in v2 unless -o given) |
| -o, --out <path> | Write result to this path (- for stdout) |
| -r/-w <fmt> | Force read/write format |
In CI
Patch a manifest before deploy: dasel put -f k8s.yaml -t string -v "$GITHUB_SHA" ".spec.template.spec.containers.[0].image". Because dasel rewrites the parsed tree, it will not corrupt YAML the way a regex replace can when the value appears more than once.
Common errors in CI
On v1 the syntax was dasel put string -f f.json .a.b val; on v2 it is dasel put -t string -v val .a.b, so a script copied across versions fails with unknown command or unknown shorthand flag. invalid integer value means -t int got a non-numeric -v. Editing in place without -o on read-only mounts gives permission denied; write to -o - and redirect instead.