Learn-skills.dev dasel
install
source · Clone the upstream repo
git clone https://github.com/NeverSight/learn-skills.dev
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/NeverSight/learn-skills.dev "$T" && mkdir -p ~/.claude/skills && cp -r "$T/data/skills-md/aaronflorey/agent-skills/dasel" ~/.claude/skills/neversight-learn-skills-dev-dasel && rm -rf "$T"
manifest:
data/skills-md/aaronflorey/agent-skills/dasel/SKILL.mdsource content
Dasel v3
Dasel (Data-Select) is a CLI tool for querying, modifying, and converting structured data files using a consistent query syntax across formats.
Docs are bundled in
. Read them when you need deeper detail on a topic.references/
CLI basics
# Read from stdin, specify input format echo '{"name":"Tom"}' | dasel -i json 'name' # => "Tom" # Read from a file via stdin redirection dasel -i yaml 'database.host' < config.yaml # Convert formats: read JSON, output YAML cat data.json | dasel -i json -o yaml # Output the whole document (needed when modifying) echo '{"a":1}' | dasel -i json --root 'a = 2' # => {"a": 2}
Key flags:
| Flag | Short | Purpose |
|---|---|---|
| | Input format (json, yaml, toml, xml, csv, hcl, ini) |
| | Output format |
| Output the full document, not just the selected value | |
| Pass a file as a named variable | |
| Parser-specific read options | |
| Parser-specific write options | |
| | Path to dasel config file (default: ) |
| Enable unstable/experimental features |
Query syntax
Queries are dot-chained accessors and function calls, terminated with
; when using multiple statements.
# Access nested fields user.address.city # Array index (zero-based) users[0].name # Range slice users[0:4] # Assign (modifies the value in the document) user.name = "Alice" # Variables - $root is stdin, $this is current element $root.users.filter(active == true).map(name)
Multi-statement queries (use
; to separate, last statement is the output):
$active = $root.users.filter(active == true); $active.map(name)
Environment variables
GREETING=hello NAME=tom dasel '$GREETING + " " + $NAME' # => "hello tom"
Common patterns
Read a value
echo '{"foo":{"bar":"baz"}}' | dasel -i json 'foo.bar' # => "baz"
Modify a value (output full document)
echo '{"foo":"old"}' | dasel -i json --root 'foo = "new"' # => {"foo": "new"}
Edit a file in place
dasel -i yaml --root 'server.port = 9090' < config.yaml > config.yaml.tmp \ && mv config.yaml.tmp config.yaml
Note: there is no
flag for data files in v3. Always use stdin (-for< file). Note: always go via a temp file — bash truncates the target before dasel reads it.cat file |
Filter an array
echo '{"users":[{"name":"Alice","active":true},{"name":"Bob","active":false}]}' \ | dasel -i json 'users.filter(active == true).map(name)' # => ["Alice"]
Map / transform
echo '[1,2,3]' | dasel -i json 'map($this * 2)' # => [2, 4, 6]
Modify elements in place with each
eachecho '[1,2,3]' | dasel -i json 'each($this = $this + 1)' # => [2, 3, 4]
Default / coalesce
# Fall back to a default if path missing dasel -f config.yaml 'server.timeout ?? 30'
Conditional
dasel -f data.json 'if(count > 5) { "many" } else { "few" }'
Recursive descent — find all values by key
# All values with key "name" at any depth dasel -f data.json '..name' # All values at any depth dasel -f data.json '..*'
Predicate-based deep search
dasel -f data.json 'search(has("id") && has("name"))'
Format conversion
cat file.json | dasel -i json -o yaml cat file.yaml | dasel -i yaml -o toml
Build a new object
echo '{"first":"Tom","last":"Wright"}' \ | dasel -i json '{"fullName": first + " " + last}'
Spread operator
# Merge objects echo '{"a":1}' | dasel -i json '{$this..., "b": 2}' # => {"a":1,"b":2} # Append to array echo '[1,2,3]' | dasel -i json '[$this..., 4, 5]' # => [1,2,3,4,5]
Supported formats
| Format | Read | Write | Notes |
|---|---|---|---|
| json | ✓ | ✓ | |
| yaml | ✓ | ✓ | |
| xml | ✓ | ✓ | See |
| csv | ✓ | ✓ | All values as strings; |
| hcl | ✓ | ✓ | |
| toml | ✓ | ✓ | Generally working; unsorted maps |
| ini | ✓ | ✓ | Basic sections + key values only |
Key functions
| Function | Description | Example |
|---|---|---|
| Filter array by predicate | |
| Transform each element | |
| Iterate and modify in place | |
| Recursive predicate search | |
| Check key/index exists | |
| Length of array/string | |
| Keys of a map | |
| Add / concatenate | |
| Join array to string | |
| String replace | |
| Sort array of objects | |
| Reverse array | |
/ | Min/max of numbers | |
| Sum numbers | |
| Convert to string | |
| Convert to int | |
| Type name | |
| Parse a string as a format | |
| Read a file | |
| Base64 encode | |
| Base64 decode | |
For full function signatures and examples, see
.references/functions.md
Reference files
| File | When to read |
|---|---|
| Deep dive: types, arrays, objects, conditionals, spread, coalesce, branches, regex, recursive descent |
| All function signatures with examples |
| Stdin/stdout, file editing, variables, format flags |
Tips
- Always use
when modifying data and wanting the full document back.--root - Use
to write multi-statement queries for clarity.;
is the stdin document;$root
is the current element inside functions.$this- For in-place file edits, always redirect to a
file first, then.tmp
.mv - The ternary operator (
) is not yet implemented — use? :
form instead.if/else
is unstable — requiresbranch
flag.--unstable