# Stdout

Dasel writes to stdout.

You can modify the output with the `-o`, `--out` flag passing the required format, e.g. `json`, `yaml` etc.

```
$ echo '{"message": "Hello world"}' | dasel -i json -o yaml
message: Hello world
```

## Getting the output you want

Dasel will output the result of the final expression by default, however in some cases it can be useful to output the input document, e.g.

### Default behaviour

```
$ echo '{"user": {"name": "John"}}' |
    dasel -i json 'user.name = {"first": user.name, "last": "Doe"}'

// outputs
{"first": "John", "last": "Doe"}
```

### With --root

<pre><code>$ echo '{"user": {"name": "John"}}' |
    dasel -i json --root 'user.name = {"first": user.name, "last": "Doe"}'

// outputs
<strong>{"user": {"name": {"first": "John", "last": "Doe"}}}
</strong></code></pre>

## Compact output

By default, dasel pretty-prints structured output with indentation and newlines. Use the `--compact` flag to produce compact output with no extra whitespace.

This is supported for JSON, TOML, YAML, and XML formats.

```
$ echo '{"name": "Tom", "age": 30}' | dasel -i json -o json --compact
{"name":"Tom","age":30}
```

```
$ echo '<Root><Name>Tom</Name></Root>' | dasel -i xml -o xml --compact
<Root><Name>Tom</Name></Root>
```


---

# 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/input-output/stdout.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.
