Dasel: A Universal CLI Tool for Data Selection and Transformation

Summary
Dasel is a powerful command-line tool and Go library designed for querying, modifying, and transforming data across various formats like JSON, YAML, TOML, XML, and CSV. It provides a consistent syntax, making it an invaluable asset for developers, DevOps professionals, and anyone involved in data wrangling tasks. Its ability to convert between formats and integrate into scripts further enhances its utility.
Repository Info
Tags
Click on any tag to explore related repositories
Introduction
Dasel, short for Data-Select, is a versatile command-line tool and Go library that simplifies querying, modifying, and transforming structured data. It supports a wide array of formats including JSON, YAML, TOML, XML, and CSV, offering a unified and powerful syntax for interacting with your data. Whether you need to extract specific values, update configurations, or convert data between different formats, Dasel provides an efficient solution.
Installation
Getting started with Dasel is straightforward. You can install it using popular package managers or directly from source.
Homebrew (macOS/Linux)
brew install dasel
Go Install
go install github.com/tomwright/dasel/v3/cmd/dasel@master
For more installation options, including prebuilt binaries, please refer to the official documentation.
Examples
Dasel's intuitive syntax makes common data manipulation tasks simple. Here are a few examples:
Selecting Values
echo '{"foo": {"bar": "baz"}}' | dasel -i json 'foo.bar'
# Output: "baz"
Modifying Values
echo '{"foo": {"bar": "baz"}}' | dasel -i json --root 'foo.bar = "bong"'
# Output:
{
"foo": {
"bar": "bong"
}
}
Format Conversion
cat data.json | dasel -i json -o yaml
Recursive Descent (..)
echo '{"foo": {"bar": "baz"}}' | dasel -i json '..bar'
# Output:
[
"baz"
]
Search (search)
echo '{"foo": {"bar": "baz"}}' | dasel -i json 'search(bar == "baz")'
# Output:
[
{
"bar": "baz"
}
]
Why Use Dasel?
Dasel stands out due to its comprehensive feature set and ease of use. Its multi-format support means you only need one tool for various data types, simplifying your workflow. The unified query syntax ensures consistency, reducing the learning curve. It's highly script-friendly, making it ideal for automation in shell scripts and CI/CD pipelines. Furthermore, its availability as a Go package allows developers to integrate its powerful capabilities directly into their Go applications.
Links
Find more information and contribute to Dasel: