---
title: '|escapeseq'
description: applies the `escape` filter to each element of a sequence.
date: '2026-08-02'
categories:
  - Filter
  - Coding
canonical: https://coolify.djangotemplatetagsandfilters.com/filters/escapeseq/
doc_link: https://docs.djangoproject.com/en/6.0/ref/templates/builtins/#escapeseq
---

# |escapeseq

applies the `escape` filter to each element of a sequence.

## Documentation

Applies the [`escape`](/filters/escape/) filter to each element of a sequence.

### Variable

```django
items = [
    '<script>alert("one")</script>',
    '<b>bold</b>',
    'plain text'
]
```

### Template

```django
{{ items|escapeseq|join:", " }}
```

### Result

```django
<script>alert("one")</script>, <b>bold</b>, plain text
```

Each element in the sequence has its HTML characters escaped before being joined.

### Use Case

This is useful when you need to join a list of items that may contain HTML, and you want to ensure each item is escaped before joining:

```django
{{ user_comments|escapeseq|join:"<br>" }}
```

Without `escapeseq`, you would need to loop through the items manually to escape each one.

## Commentary

This filter complements [`safeseq`](/filters/safeseq/), which does the opposite (marks each element as safe). Use `escapeseq` when you have a sequence of potentially unsafe strings that you need to escape before joining or further processing.

See also: [`escape`](/filters/escape/), [`safeseq`](/filters/safeseq/).
