---
title: '|linebreaks'
description: converts newlines to `<br>` and `<p>` tags.
date: '2026-08-02'
categories:
  - Filter
  - Coding
canonical: https://coolify.djangotemplatetagsandfilters.com/filters/linebreaks/
doc_link: https://docs.djangoproject.com/en/6.0/ref/templates/builtins/#linebreaks
---

# |linebreaks

converts newlines to `<br>` and `<p>` tags.

## Documentation

Replaces single newline characters with `<br>` tags and wraps lines of text separated by two newline characters in `<p>` tags.

### Variable

```django
poem = '''Much to his Mum and Dad’s dismay,
Horace ate himself one day.

He didn’t stop to say his grace,
He just sat down and ate his face.

“We can’t have this!” His Dad declared,
“If that lad’s ate, he should be shared.”'''
```

### Template

```django
{{ poem|linebreaks }}
```

### Result

```django
<p>Much to his Mum and Dad’s dismay,<br>Horace ate himself one day.</p>
<p>He didn’t stop to say his grace,<br>He just sat down and ate his face.</p>
<p>“We can’t have this!” His Dad declared,<br>“If that lad’s ate, he should be shared.”</p>
```
