---
title: '|escape'
description: escapes HTML characters.
date: '2026-08-02'
categories:
  - Filter
  - Coding
canonical: https://coolify.djangotemplatetagsandfilters.com/filters/escape/
doc_link: https://docs.djangoproject.com/en/6.0/ref/templates/builtins/#escape
---

# |escape

escapes HTML characters.

## Documentation

Escapes HTML characters.

### Variable

```django
blurb = '<p>You are <em>pretty</em> smart!</p>'
```

### Template

```django
{% autoescape off %}
  <code>{{ blurb|escape }}</code> will output:
  {{ blurb }}
{% endautoescape %}
```

### Result

```django
<code><p>You are <em>pretty</em> smart!</p></code> will output:
<p>You are <em>pretty</em> smart!</p>
```

The browser output would be:

`<p>You are <em>pretty</em> smart!</p>` will output:

You are *pretty* smart!

> The `escape` filter is only relevant if [autoescaping is off](/tags/autoescape/).
