# trim() in Jira Automation: syntax and examples

URL: https://goingstellar.ro/reference/smart-values/trim/

trim() removes whitespace from the start and end of a text value. Use it on pasted titles, on values built by concat(), and before comparing or counting text.

## Syntax

```
{{issue.summary.trim()}}
```

## Works on

- Fields: any text value
- Returns: the text without leading or trailing whitespace

## Examples

```
{{issue.summary.trim()}}
```

On a clean summary nothing changes, so it is safe to add as a habit.

Result:

```
Hello World!
```

Run on Jira Cloud on 29 Nov 2026.

```
{{issue.summary.concat("   ").concat("|")}}
```

The marker at the end shows that the three added spaces are there.

Result:

```
Hello World!   |
```

Run on Jira Cloud on 29 Nov 2026.

```
{{issue.summary.concat("   ").trim().concat("|")}}
```

With trim() the marker sits directly after the last character.

Result:

```
Hello World!|
```

Run on Jira Cloud on 29 Nov 2026.

```
{{issue.summary.concat("   ").trim().length()}}
```

Back to 12 characters, which is what a length check should see.

Result:

```
12
```

Run on Jira Cloud on 29 Nov 2026.

```
{{issue.summary.replace("Hello","   Hello").trim()}}
```

Removes spaces at the start as well as the end.

Result:

```
Hello World!
```

Run on Jira Cloud on 29 Nov 2026.

```
{{issue.summary.replace(" ","   ").trim()}}
```

Spaces between words are left alone.

Result:

```
Hello   World!
```

Run on Jira Cloud on 29 Nov 2026.

## Pitfalls

- trim() only touches the two ends. The spaces between words remain, so a split on a single space of the result gave 4 pieces for a title with three spaces between the words (checked on Jira Cloud, November 2026). Use `replaceAll("\s+"," ")` to collapse the middle.
- In a log line or a comment the extra spaces are invisible. Add a visible marker such as `|` after the value while you test, as in the examples.

## Related

- [length()](https://goingstellar.ro/reference/smart-values/length/)
- [replace(), replaceAll() and remove()](https://goingstellar.ro/reference/smart-values/replace/)
- [split()](https://goingstellar.ro/reference/smart-values/split/)
- [concat()](https://goingstellar.ro/reference/smart-values/concat/)
- [isEmpty() and isNotEmpty()](https://goingstellar.ro/reference/smart-values/isempty-isnotempty/)

## Sources

- [Jira smart values: text fields (Atlassian Support)](https://support.atlassian.com/cloud-automation/docs/jira-smart-values-text-fields/)

