> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ghost.org/llms.txt
> Use this file to discover all available pages before exploring further.

# json

> Usage: `{{json value}}` or `{{json foo="bar" count=1}}`

***

The `{{json}}` helper safely serializes a value to JSON for inline output in your theme.

This is especially useful when you need to pass server-rendered data into a `<script type="application/json">` block or into a JavaScript-powered UI.

## Example Code

```handlebars theme={"dark"}
<script id="theme-config" type="application/json">
    {{json accent=@site.accent_color title=@site.title}}
</script>
```

The helper outputs escaped JSON that is safe to embed inline:

```json theme={"dark"}
{"accent":"#FF1A75","title":"My site"}
```

## Passing an object

```handlebars theme={"dark"}
{{json @site}}
```

## Passing named values

If you pass hash arguments, `{{json}}` serializes those named values instead:

```handlebars theme={"dark"}
{{json title=@site.title url=@site.url membersEnabled=@site.members_enabled}}
```

## Notes

* Returns `null` when the input value is `undefined`
* Escapes unsafe characters such as `<`, `>` and `&` for inline script safety
* Intended for JSON output, not for formatting arbitrary HTML
