# first

Source: https://zotonic.com/docs/1761/first

URI: https://zotonic.com/id/1761

Language: en



Returns the first character or element.

Returns the first byte of a binary or the first element of a list. An empty binary is returned when the input is empty.

For example:

```django
{{ value|first }}
```

If the value is `hello` then the output is `h`.

::: {.note title="Note"}
This function is safe to use with multibyte character values, if the input is a binary.
:::

For a regular list:

```django
{{ [1,2,3]|first }}
```

The filtered value is `1`.

It is also possible to fetch the first N elements or characters:

```django
{{ [1,2,3]|first:2 }}
```

The filtered value is `[1,2]`.

Or, with a string:

```django
{{ "hello"|first:2 }}
```

The filtered value is `"he"`.

License: 

Attribution: 

Related resources: https://zotonic.com/api/agent/related/1761?language=en


## API access

- [API help](<https://zotonic.com/api-help>)
- [OpenAPI specification](<https://zotonic.com/openapi.json>)
- [This resource as JSON](<https://zotonic.com/api/agent/resource/1761?language=en>)
