> ## Documentation Index
> Fetch the complete documentation index at: https://errand.nuvrel.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# chomp

> Remove trailing newline characters from a string.

`chomp(str)` removes trailing newline characters (`\n`, `\r\n`, and `\r`) from the end of a string. It does not affect newlines in the middle of the string.

## Signature

```
chomp(str string) string
```

## Example

Read a version file and strip the trailing newline before using it in a command:

```hcl theme={null}
computed "version" {
  description = "Application version from the VERSION file"
  expression  = chomp(file("VERSION"))
}

task "tag" {
  description = "Tag the current commit with the version"
  commands = [
    "git tag v${computed.version}",
    "git push origin v${computed.version}",
  ]
}
```

`file("VERSION")` reads the file contents including any trailing newline. `chomp` removes it so the version is clean for use in the git tag.

## Notes

* `chomp` removes only trailing newlines, not spaces or tabs. Use [`trimspace`](/functions/string/trimspace) to strip all whitespace.
* If the string does not end with a newline, it is returned unchanged.
