# Dasel — Query and Modify JSON, YAML, TOML, XML, and CSV from the CLI > Dasel is a command-line tool for querying and updating data structures across multiple formats including JSON, YAML, TOML, XML, INI, HCL, KDL, and CSV using a unified selector syntax. ## Install Save in your project root: # Dasel — Query and Modify JSON, YAML, TOML, XML, and CSV from the CLI ## Quick Use ```bash go install github.com/TomWright/dasel/v2/cmd/dasel@master # Read a value from JSON echo '{"name":"dasel"}' | dasel -r json 'name' # Convert YAML to JSON dasel -r yaml -w json < config.yaml ``` ## Introduction Dasel (Data Selector) provides a single tool for reading, writing, and converting between structured data formats. Instead of learning separate query languages for jq, yq, xmlstarlet, and others, you use one selector syntax that works the same way across all supported formats. ## What Dasel Does - Reads and writes JSON, YAML, TOML, XML, CSV, INI, HCL, and KDL files - Selects nested values using dot-notation and array index selectors - Modifies values in place with put commands - Converts between formats by specifying different read and write parsers - Supports piping from stdin and writing to stdout for shell integration ## Architecture Overview Dasel parses input into an internal tree representation regardless of the source format. Selectors navigate this tree to locate target nodes. Modifications update the tree in memory, then the output formatter serializes the tree back to the requested format. This design means all features work identically across all supported data formats. ## Self-Hosting & Configuration - Install via `go install`, Homebrew, Scoop, or download release binaries - No configuration files; all options are passed as command-line arguments - Use `-r` flag to specify input format and `-w` flag for output format - Pipe data through stdin or pass file paths as arguments - Chain multiple selectors for deep nested access ## Key Features - Unified selector syntax across eight data formats - In-place file editing with the `-w` flag pointing to the same file - Format conversion in a single command - Support for array filtering, dynamic selectors, and wildcards - Zero external dependencies as a single compiled binary ## Comparison with Similar Tools - **jq** — JSON-only, more powerful query language but limited to one format - **yq** — Focuses on YAML with JSON support, different selector syntax - **xq** — XML wrapper around jq, does not support YAML or TOML - **Miller** — Excels at tabular data (CSV/TSV) but limited structured data support ## FAQ **Q: Can dasel modify files in place?** A: Yes. Use `dasel put -r json -w json -f config.json 'key' -v 'value'` to update a key directly in the file. **Q: How do I select array elements?** A: Use bracket notation: `dasel -r json 'users.[0].name'` selects the name of the first user. **Q: Does dasel preserve comments in YAML?** A: No. Comments are not part of the data model and are dropped during parsing, which is a limitation shared with most programmatic YAML tools. **Q: Can I use dasel in CI/CD pipelines?** A: Yes. It is a single binary with no dependencies, making it easy to add to Docker images or CI runners. ## Sources - https://github.com/TomWright/dasel - https://daseldocs.tomwright.me --- Source: https://tokrepo.com/en/workflows/asset-4b6edef1 Author: AI Open Source