---
title: math
description: "Format inline math or a math block."
---

# math

Format inline math or a math block.

## Syntax

```knap
{{ value | math }}
```

## Usage

- Multiline data automatically becomes a block delimited by `$$`.
- Leading and trailing whitespace stays outside inline markers.
- For arrays and objects, including serialized collections from another filter, string values are formatted recursively while keys and non-string values are preserved.

## Example

```json title="Data"
{
  "expression": "x^2 + y^2"
}
```

```knap title="Template"
{{ expression | math }}
```

```md title="Output"
$x^2 + y^2$
```

## Related filters

- [math_block](/filters/math-block)
