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

# TRIM

> Removes characters from the beginning, end or both ends of a string.

<div className="e6-meta"><span className="e6-eyebrow e6-eyebrow--quiet">Scalar function</span></div>

NULL subject or NULL trim characters returns NULL; an empty string remains empty.

## Syntax

### Scalar

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
TRIM([mode] [characters] FROM value)
```

## Arguments

| Name | Type | Required | Description |
| - | - | - | - |
| mode | BOTH, LEADING or TRAILING keyword | No | Side to trim. Must be a constant argument. Default: BOTH. |
| characters | STRING | No | Characters to trim. Default: space. |
| value | STRING | Yes | String to trim. |

## Returns

* Type: STRING
* NULL behavior: NULL subject or NULL trim characters returns NULL; an empty string remains empty.

## Properties

| Property | Value |
| - | - |
| Deterministic | Yes |
| Supports window usage | No |
| Exact result | Yes |

## Usage notes

* The trim option selects whether characters are removed from the start, end, or both ends of the text.
* Deterministic: The same inputs and settings produce the same result.

## Examples

### Typical behavior

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
SELECT TRIM(BOTH ' ' FROM '  Hello  ') AS "value";
```

| value |
| - |
| Hello |

### Choose the characters to remove

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
SELECT TRIM(BOTH '.' FROM '..hello..') AS trimmed;
```

| trimmed |
| - |
| hello |

## Related functions

* [ltrim](/query/sql/functions/string/ltrim)
* [rtrim](/query/sql/functions/string/rtrim)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.