---
title: escape_md
description: "Escape Markdown punctuation so text renders literally."
---

# escape_md

Escape Markdown punctuation so text renders literally.

## Syntax

```knap
{{ value | escape_md }}
```

## Usage

- Every ASCII punctuation character supported by Markdown backslash escapes is prefixed with a backslash.
- Existing backslashes are escaped so they remain visible.
- 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"
{
  "text": "# Draft *title*"
}
```

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

```md title="Output"
\# Draft \*title\*
```

## Related filters

- [code](/filters/code)
- [strip_md](/filters/strip-md)
