---
title: '|capfirst'
description: capitalizes the first letter of a value.
date: '2026-08-02'
categories:
  - Filter
  - Formatting
canonical: https://www.djangotemplatetagsandfilters.com/filters/capfirst/
doc_link: https://docs.djangoproject.com/en/6.0/ref/templates/builtins/#capfirst
---

# |capfirst

capitalizes the first letter of a value.

## Documentation

Capitalizes the first letter of a value.

### Variable

```django
greeting = 'hello, world!'
```

### Template

```django
{{ greeting|capfirst }}
```

### Result

```django
Hello, world!
```

## Commentary

In general, we prefer using CSS to formatting filters like this one; however, there is no CSS property equivalent to the `capfirst` filter. CSS's `text-transform: capitalize` property works like the [`title`](/filters/title/) filter (i.e., it capitalizes the first letter of each word). Also, there is an advantage to using Django: because the formatting is applied server-side, the value returned to the client will already be formatted appropriately. If the client does not support CSS or has CSS turned off, that will not affect the formatting.

And, of course, if you are using Django to output plain text or some other non-HTML format, formatting filters could come in handy.
