# ansible.builtin.to_json
Converts an Ansible variable into a [JSON](../../../files/JSON.md) string representation.

## Examples
```yml
# dump variable in a template to create a JSON document
{{ docker_config | to_json }}

# same as above but 'prettier' (equivalent to to_nice_json filter)
{{ docker_config | to_json(indent=4, sort_keys=True) }}
```