| 1 | [](https://daseldocs.tomwright.me) |
| 2 | [](https://goreportcard.com/report/github.com/tomwright/dasel/v3) |
| 3 | [](https://pkg.go.dev/github.com/tomwright/dasel/v3) |
| 4 |  |
| 5 |  |
| 6 | [](https://codecov.io/gh/TomWright/dasel) |
| 7 | [](https://github.com/avelino/awesome-go) |
| 8 |  |
| 9 |  |
| 10 |  |
| 11 | [](https://github.com/TomWright/dasel/releases/latest) |
| 12 | [](https://formulae.brew.sh/formula/dasel) |
| 13 | |
| 14 | <div align="center"> |
| 15 | <img src="./daselgopher.png" alt="Dasel mascot" width="250"/> |
| 16 | </div> |
| 17 | |
| 18 | # Dasel |
| 19 | |
| 20 | Dasel (short for **Data-Select**) is a command-line tool and library for querying, modifying, and transforming data structures such as JSON, YAML, TOML, XML, CSV, and KDL. |
| 21 | |
| 22 | It provides a consistent, powerful syntax to traverse and update data — making it useful for developers, DevOps, and data wrangling tasks. |
| 23 | |
| 24 | --- |
| 25 | |
| 26 | ## Features |
| 27 | |
| 28 | * **Multi-format support**: JSON, YAML, TOML, XML, CSV, HCL, INI, KDL. |
| 29 | * **Unified query syntax**: Access data in any format with the same selectors. |
| 30 | * **Query & search**: Extract values, lists, or structures with intuitive syntax. |
| 31 | * **Modify in place**: Update, insert, or delete values directly in structured files. |
| 32 | * **Convert between formats**: Seamlessly transform data from JSON → YAML, TOML → JSON, etc. |
| 33 | * **Script-friendly**: Simple CLI integration for shell scripts and pipelines. |
| 34 | * **Library support**: Import and use in Go projects. |
| 35 | |
| 36 | --- |
| 37 | |
| 38 | ## Installation |
| 39 | |
| 40 | ### Homebrew (macOS/Linux) |
| 41 | |
| 42 | ```sh |
| 43 | brew install dasel |
| 44 | ``` |
| 45 | |
| 46 | ### Go Install |
| 47 | |
| 48 | ```sh |
| 49 | go install github.com/tomwright/dasel/v3/cmd/dasel@master |
| 50 | ``` |
| 51 | |
| 52 | ### Prebuilt Binaries |
| 53 | |
| 54 | Prebuilt binaries are available on the [Releases](https://github.com/TomWright/dasel/releases) page for Linux, macOS, and Windows. |
| 55 | |
| 56 | ### None of the above? |
| 57 | |
| 58 | See the [installation docs](https://daseldocs.tomwright.me/getting-started/installation) for more options. |
| 59 | |
| 60 | --- |
| 61 | |
| 62 | ## Shell Completion |
| 63 | |
| 64 | Dasel supports tab-completion for Bash, Zsh, Fish, and PowerShell. Generate and load the completion script for your shell: |
| 65 | |
| 66 | ```sh |
| 67 | # Bash |
| 68 | source <(dasel completion bash) |
| 69 | |
| 70 | # Zsh |
| 71 | source <(dasel completion zsh) |
| 72 | |
| 73 | # Fish |
| 74 | dasel completion fish | source |
| 75 | |
| 76 | # PowerShell |
| 77 | dasel completion powershell | Out-String | Invoke-Expression |
| 78 | ``` |
| 79 | |
| 80 | See the [shell completion docs](https://daseldocs.tomwright.me/getting-started/shell-completion) for permanent installation instructions. |
| 81 | |
| 82 | ## Man Page |
| 83 | |
| 84 | Generate and view the man page: |
| 85 | |
| 86 | ```sh |
| 87 | dasel man | man -l - |
| 88 | ``` |
| 89 | |
| 90 | --- |
| 91 | |
| 92 | ## Basic Usage |
| 93 | |
| 94 | ### Selecting Values |
| 95 | |
| 96 | By default, Dasel evaluates the final selector and prints the result. |
| 97 | |
| 98 | ```sh |
| 99 | echo '{"foo": {"bar": "baz"}}' | dasel -i json 'foo.bar' |
| 100 | # Output: "baz" |
| 101 | ``` |
| 102 | |
| 103 | ### Modifying Values |
| 104 | |
| 105 | Update values inline: |
| 106 | |
| 107 | ```sh |
| 108 | echo '{"foo": {"bar": "baz"}}' | dasel -i json 'foo.bar = "bong"' |
| 109 | # Output: "bong" |
| 110 | ``` |
| 111 | |
| 112 | Use `--root` to output the full document after modification: |
| 113 | |
| 114 | ```sh |
| 115 | echo '{"foo": {"bar": "baz"}}' | dasel -i json --root 'foo.bar = "bong"' |
| 116 | # Output: |
| 117 | { |
| 118 | "foo": { |
| 119 | "bar": "bong" |
| 120 | } |
| 121 | } |
| 122 | ``` |
| 123 | |
| 124 | Update values based on previous value: |
| 125 | |
| 126 | ```sh |
| 127 | echo '[1,2,3,4,5]' | dasel -i json --root 'each($this = $this*2)' |
| 128 | # Output: |
| 129 | [ |
| 130 | 2, |
| 131 | 4, |
| 132 | 6, |
| 133 | 8, |
| 134 | 10 |
| 135 | ] |
| 136 | ``` |
| 137 | |
| 138 | ### Format Conversion |
| 139 | |
| 140 | ```sh |
| 141 | cat data.json | dasel -i json -o yaml |
| 142 | ``` |
| 143 | |
| 144 | ### Recursive Descent (`..`) |
| 145 | |
| 146 | Searches all nested objects and arrays for a matching key or index. |
| 147 | |
| 148 | ```sh |
| 149 | echo '{"foo": {"bar": "baz"}}' | dasel -i json '..bar' |
| 150 | # Output: |
| 151 | [ |
| 152 | "baz" |
| 153 | ] |
| 154 | |
| 155 | ``` |
| 156 | |
| 157 | ### Search (`search`) |
| 158 | |
| 159 | Finds all values matching a condition anywhere in the structure. |
| 160 | |
| 161 | ```sh |
| 162 | echo '{"foo": {"bar": "baz"}}' | dasel -i json 'search(bar == "baz")' |
| 163 | # Output: |
| 164 | [ |
| 165 | { |
| 166 | "bar": "baz" |
| 167 | } |
| 168 | ] |
| 169 | |
| 170 | ``` |
| 171 | |
| 172 | --- |
| 173 | |
| 174 | ## Documentation |
| 175 | |
| 176 | Full documentation is available at [daseldocs.tomwright.me](https://daseldocs.tomwright.me). |
| 177 | |
| 178 | --- |
| 179 | |
| 180 | ## Contributing |
| 181 | |
| 182 | Contributions are welcome! Please see the [CONTRIBUTING.md](./CONTRIBUTING.md) for details. |
| 183 | |
| 184 | --- |
| 185 | |
| 186 | ## License |
| 187 | |
| 188 | MIT License. See [LICENSE](./LICENSE) for details. |
| 189 | |
| 190 | ## Stargazers over time |
| 191 | |
| 192 | [](https://starchart.cc/TomWright/dasel) |