---
title: TRUNCATEWORDS
url: https://www.tines.com/docs/formulas/functions/truncatewords/
kind: formula-function
---

*[tines.com](https://www.tines.com/llms.txt) › [Docs](https://www.tines.com/docs/llms.txt) › [Formulas](https://www.tines.com/llm/docs/formulas.md) › [Functions](https://www.tines.com/llm/docs/formulas/functions.md)*

# TRUNCATEWORDS

*[View on tines.com](https://www.tines.com/docs/formulas/functions/truncatewords/)*

Shortens text down to the number of words passed as the argument.

If the specified number of words is less than the number of words in the text, `...` is appended to the text.

**Categories:** Text

## Syntax

```
TRUNCATEWORDS(text, length, [ellipsis])
```

## Examples

### Example 1

Input:

```json
{
  "my_action": {
    "message": "Hello and welcome to Tines"
  }
}
```

Formula:

```
TRUNCATEWORDS(my_action.message, 3)
```

Output:

```json
"Hello and welcome..."
```

### Example 2: An optional third argument controls the characters inserted if the text is truncated (instead of `...`):

Input:

```json
{
  "my_action": {
    "message": "Hello and welcome to Tines"
  }
}
```

Formula:

```
TRUNCATEWORDS(my_action.message, 3, " etc")
```

Output:

```json
"Hello and welcome etc"
```

### Example 3: Setting the third argument to `""` prevents any text being inserted if the text is truncated:

Input:

```json
{
  "my_action": {
    "message": "Hello and welcome to Tines"
  }
}
```

Formula:

```
TRUNCATEWORDS(my_action.message, 3, "")
```

Output:

```json
"Hello and welcome"
```

## Sample actions

```json
{
  "standardLibVersion": "14",
  "actionRuntimeVersion": "3",
  "agents": [
    {
      "disabled": false,
      "name": "My Action",
      "description": "",
      "options": {
        "mode": "message_only",
        "loop": false,
        "payload": {
          "example": "This is for a insert here"
        }
      },
      "position": {
        "x": 615,
        "y": 3975
      },
      "type": "eventTransformation",
      "timeSavedUnit": "minutes",
      "timeSavedValue": 0,
      "monitorAllEvents": false,
      "monitorFailures": false,
      "monitorNoEventsEmitted": null,
      "form": null
    },
    {
      "disabled": false,
      "name": "TRUNCATE WORDS",
      "description": "-Truncate words will use the assigned path: my_action.example\n\n-then the number is the number of WORDS to retain, then it replaces every word after word 4 in this example\n\n-then it will replace everything that follows word 4 with whatever is in quotations, in this case the word \"test\" will be the replacement of 'insert here'",
      "options": {
        "mode": "message_only",
        "loop": false,
        "payload": {
          "Truncate_words": "=TRUNCATEWORDS(my_action.example, 4, \" test\")"
        }
      },
      "position": {
        "x": 615,
        "y": 4095
      },
      "type": "eventTransformation",
      "timeSavedUnit": "minutes",
      "timeSavedValue": 0,
      "monitorAllEvents": false,
      "monitorFailures": false,
      "monitorNoEventsEmitted": null,
      "form": null
    }
  ],
  "links": [
    {
      "sourceIdentifier": 0,
      "receiverIdentifier": 1
    }
  ],
  "diagramNotes": []
}
```
