---
title: '|force_escape'
description: Almost identical to `escape`.
date: '2026-08-02'
categories:
  - Filter
  - Coding
canonical: https://www.djangotemplatetagsandfilters.com/filters/force_escape/
doc_link: https://docs.djangoproject.com/en/6.0/ref/templates/builtins/#force-escape
---

# |force_escape

Almost identical to `escape`.

## Documentation

Almost identical to `escape`, and you almost definitely want to use `escape` instead.

### Variable

```django
shopping_list = '''Carrots
Honey
Milk
Butter'''
```

### Template with `force_escape`

```django
{% autoescape off %}
    {{ shopping_list|linebreaks|force_escape }}
{% endautoescape %}
```

### Result

```django
<p>Carrots<br>Honey<br>Milk<br>Butter</p>
```

### Template with `escape`

```django
{% autoescape off %}
    {{ shopping_list|linebreaks|escape }}
{% endautoescape %}
```

### Result with `escape`

```django
<p>Carrots<br>Honey<br>Milk<br>Butter</p>
```

Notice that the `<br>` tags that are generated with the [`linebreaks`](/filters/linebreaks/) filter are escaped when `force_escape` is used, but not when `escape` is used.

## Commentary

You are very unlikely to need this.
