LinuxCommandLibrary

dasel

Select, update, and convert data structures

SYNOPSIS

dasel [global-options...] <select-expression> [<input-file>|-]...

PARAMETERS

-a, --all
    Read and process all input files

-c, --color <when>
    Color output: always|never|auto (default: auto)

-d, --delete <delete-expr>
    Delete data matching expression

-f, --file <files...>
    Input files (default: stdin)

-i, --inplace
    Edit input files in place

-m, --match <match-exprs...>
    Only process paths matching expressions

-r, --raw-output
    Output primitive values without quotes

-s, --set <set-exprs...>
    Set data using path=value expressions

-w, --writer <format>
    Output format: json|yaml|toml|xml|csv|go-template (default: inferred)

-h, --help
    Show help

--version
    Print version

DESCRIPTION

Dasel is a versatile command-line tool for selecting, querying, modifying, and deleting data from structured files in multiple formats: JSON, YAML, TOML, XML, CSV, and more. Inspired by jq's powerful query language, dasel provides a unified syntax across formats, eliminating the need for format-specific tools like yq or xq.

It reads input from files or stdin, applies expressions to traverse and filter data (e.g., users[].name), and supports operations like setting values (-s), deletion (-d), and path matching (-m). Output can be raw, colored, or rewritten in various formats via the -w writer option.

Ideal for automation in DevOps, scripting, and config processing, dasel handles large datasets efficiently thanks to its Go implementation. It supports inplace editing, reading multiple files with -a, and even querying environment variables or Kubernetes resources. Expressions use dot notation for objects, brackets for arrays, and functions like length, keys, or has.

With dasel, a single command like dasel 'items.*.name' config.yaml extracts nested data seamlessly, making it a go-to for portable data extraction pipelines.

CAVEATS

May consume high memory on very large files; limited support for some CSV dialects or deeply nested XML; expressions are jq-like but not fully compatible with jq extensions.

BASIC EXAMPLES

Extract names: dasel 'users[].name' data.json
Convert YAML to JSON: dasel -w json '.' config.yaml
Set value: dasel -i -s '.debug=true' config.yaml

INSTALLATION

Via Go: go install github.com/TomWright/dasel/cmd/dasel@latest
Binaries: GitHub releases; package managers like Homebrew (brew install dasel).

HISTORY

Developed by Tom Wright in 2020 as a Go-based alternative to format-specific query tools. First release v1.0.0 in 2021; actively maintained with v2+ adding writers, sets, and deletes. Gained popularity for multi-format support in CI/CD pipelines.

SEE ALSO

jq(1), yq(1), xq(1), tomlq(1)

Copied to clipboard