---
schema_version: "1"
id: 274978cff6abb783486c02c0a5fd5db8b0507028204fe71d7626a6c46270939f
title: TRIM
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/data-cloud/data-cloud-query-guide/references/data-cloud-sql-reference/scalar-func/string-func/trim.md
canonical_url: https://developer.salesforce.com/docs/data/data-cloud-query-guide/references/dc-sql-reference/trim.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: e80c6e37e355c7ad439060b2fc7d0cb105d57fe908fb5ad99375b185ac5503b7
products:
  - Data 360 Query Guide
  - Data 360 Developer Documentation
---
# `TRIM`

**Applies to:** ✅ Data 360 SQL ✅ Tableau Hyper API

Removes specified characters from the start, end, or both ends of a string.

## Syntax

```sql
trim([leading | trailing | both] [characters] from <string>)
```

## Arguments

### Required

- `<string>`: The string to trim.

### Optional

- `mode`: Where to trim from (`leading`, `trailing`, or `both`). Defaults to `both`.
- `characters`: The characters to remove. Defaults to space.

## Returns

Returns a text value with specified characters removed.

## Considerations

- Removes individual characters from the set, not the string as a pattern.
- Default behavior removes spaces from both ends.

## Examples

### Trim Characters

Remove specified characters from both ends.

```sql
SELECT trim(both 'xyz' from 'yxTomxx') AS result;
```

Returns `'Tom'`, removing all `x`, `y`, and `z` characters from both ends.

## Related Documentation

- [String Types](https://developer.salesforce.com/docs/data/data-cloud-query-guide/datatype/string.md)
