Configs2026年7月5日·1 分钟阅读

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.

Agent 就绪

这个资产会安全暂存

这个资产会先安全暂存。复制的指令会要求 Agent 读取暂存文件,并在激活脚本、MCP 配置或全局配置前先确认。

Stage only · 29/100策略:需暂存
Agent 入口
任意 MCP/CLI Agent
类型
CLI Tool
安装
Single
信任
信任等级:Established
入口
Dasel Overview
安全暂存命令
npx -y tokrepo@latest install 4b6edef1-784d-11f1-9bc6-00163e2b0d79 --target codex

先暂存文件;激活前需要读取暂存 README 和安装计划。

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

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产