> For the complete documentation index, see [llms.txt](https://motivlabs.gitbook.io/impulse-user-manual/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://motivlabs.gitbook.io/impulse-user-manual/content-manipulators-motators/liquid-field/filters/truncatewords.md).

# truncatewords

Shortens a string down to the number of words passed as an argument. If the specified number of words is less than the number of words in the string, an ellipsis (…) is appended to the string.

Input

```
{{ "Ground control to Major Tom." | truncatewords: 3 }}
```

Output

```
Ground control to...
```

#### Custom ellipsis <a href="#custom-ellipsis" id="custom-ellipsis"></a>

`truncatewords` takes an optional second argument that specifies the sequence of characters to be appended to the truncated string. By default this is an ellipsis (…), but you can specify a different sequence.

Input

```
{{ "Ground control to Major Tom." | truncatewords: 3, "--" }}
```

Output

```
Ground control to--
```

#### No ellipsis <a href="#no-ellipsis" id="no-ellipsis"></a>

You can avoid showing trailing characters by passing a blank string as the second argument.

Input

```
{{ "Ground control to Major Tom." | truncatewords: 3, "" }}
```

Output

```
Ground control to
```
