---
title: indent
description: "Indent each non-empty line with spaces."
---

# indent

Indent each non-empty line with spaces.

## Syntax

```knap
{{ value | indent }}
{{ value | indent:2 }}
```

## Usage

- The optional width is an integer from 0 to 1000. It defaults to two spaces; zero leaves the text unchanged.
- Indents the first line as well as subsequent lines. Existing indentation, empty lines, and line endings are preserved.

## Examples

### Basic usage

```json title="Data"
{
  "text": "First\nSecond"
}
```

```knap title="Template"
{{ text | indent }}
```

```md title="Output"
  First
  Second
```

### Choose a width

```json title="Data"
{
  "text": "- One\n- Two"
}
```

```knap title="Template"
{{ text | indent:4 }}
```

```md title="Output"
    - One
    - Two
```

## Related filters

- [yaml](/filters/yaml)
- [trim](/filters/trim)
