# Delete

## Description

This command allows you to delete data at a given selector.

If the root node is deleted, an empty node of the same type will be output.

Note that if your root node is anything other than an object or array, dasel will output an empty object.

{% hint style="info" %}
Available since `v1.16.0.`
{% endhint %}

## Usage

```shell
dasel delete -f <file> <selector>
```

{% hint style="warning" %}
If `--file` is used without `--out` then the source file will be updated.
{% endhint %}

| Flag                             | Description                                                                                                                                                                                                                                                                     |
| -------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `-f`, `--file`                   | <p>Specify the file to query. This is required unless you are piping in data.</p><p>If piping in data you can optionally pass <code>-f stdin</code>/<code>-f -</code>.</p>                                                                                                      |
| `-o`, `--out`                    | <p>Specify the output file. If present, results will be written to the given file. If not present, results will be written to the input file (or stdout if none given).</p><p>To force output to be written to stdout, pass <code>-o stdout</code>or<code>-o -</code>.</p>      |
| `-r`, `--read`                   | <p>Specify the parser to use when reading the input data.</p><p>This is required if you are piping in data, otherwise dasel will use the given file extension to guess which parser to use.</p><p>See <a href="/pages/-MXgNylC4AkvSj351jU3">supported file types</a>.</p>       |
| `-w`, `--write`                  | <p>Specify the parser to use when writing the output data.</p><p>If not provided dasel will attempt to use the <code>--out</code> and <code>--read</code> flags to determine which parser to use.</p><p>See <a href="/pages/-MXgNylC4AkvSj351jU3">supported file types</a>.</p> |
| `-p`, `--parser`                 | Shorthand for `-r <value> -w <value>`                                                                                                                                                                                                                                           |
| `-m`, `--multiple`               | <p>Tells dasel to delete multiple items.</p><p>See <a href="/pages/-MXgNylAqqL66l3g7A2u">multiple</a>.</p>                                                                                                                                                                      |
| `-s`, `--selector`, `<selector>` | <p>Specify the selector to use. See <a href="/pages/-MXgNylFbABKYJMirPOA">selectors</a> for more information.</p><p>If no selector flag is given, dasel assumes the first argument given is the selector.</p><p>This is required.</p>                                           |
| `--plain`                        | <p>By default, dasel formats the output using the specified parser.</p><p>If this flag is used no formatting occurs and the results output as a string.</p>                                                                                                                     |
| `-c`, `--compact`                | This tells dasel to output compact data where possible. E.g. not pretty printing JSON.                                                                                                                                                                                          |
| `--merge-input-documents`        | See [merge input documents](/v1/usage/flags/merge-input-documents.md).                                                                                                                                                                                                          |
| `--escape-html`                  | See [escape html](/v1/usage/flags/escape-html.md).                                                                                                                                                                                                                              |

## Example

### Delete property

```shell
$ echo '{
  "name": "Tom",
  "email": "contact@tomwright.me"
}' | dasel delete -p json '.email'
{
  "name": "Tom"
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://daseldocs.tomwright.me/v1/usage/delete.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
