# ltrim

> For the complete documentation index, see [llms.txt](https://docs.redpanda.com/llms.txt). Component-specific: [cloud-data-platform-full.txt](https://docs.redpanda.com/cloud-data-platform-full.txt)

---
title: ltrim
latest-operator-version: v26.2.4
latest-console-tag: v3.12.0
latest-connect-version: 4.113.0
latest-redpanda-tag: v26.2.4
docname: sql/sql-functions/string-functions/ltrim
page-component-name: cloud-data-platform
page-version: master
page-component-version: master
page-component-title: Cloud
page-relative-src-path: sql/sql-functions/string-functions/ltrim.adoc
page-edit-url: https://github.com/redpanda-data/cloud-docs/edit/main/modules/reference/pages/sql/sql-functions/string-functions/ltrim.adoc
description: The `ltrim()` function removes the longest string of characters matching a set of characters from the start of a string.
page-topic-type: reference
page-git-created-date: "2026-09-08"
page-git-modified-date: "2026-09-08"
---

<!-- Source: https://docs.redpanda.com/cloud-data-platform/reference/sql/sql-functions/string-functions/ltrim.md -->

The `ltrim()` function removes the longest string containing only characters from a specified set from the start (left side) of a string. If you don’t specify a set of characters, `ltrim()` removes spaces.

See also [`rtrim()`](https://docs.redpanda.com/cloud-data-platform/reference/sql/sql-functions/string-functions/rtrim/) to trim from the end of a string, [`btrim()`](https://docs.redpanda.com/cloud-data-platform/reference/sql/sql-functions/string-functions/btrim/) to trim from both ends, and [`trim()`](https://docs.redpanda.com/cloud-data-platform/reference/sql/sql-functions/string-functions/trim/) for the SQL-standard `TRIM(…​ FROM …​)` syntax.

## [](#syntax)Syntax

The syntax of the `ltrim()` function is:

```sql
LTRIM(string)
LTRIM(string, characters)
```

The `ltrim()` function accepts the following arguments:

-   `string`: The string to trim.

-   `characters`: Optional. The set of characters to remove from the start of `string`. Defaults to a space character.


## [](#examples)Examples

### [](#trim-leading-spaces)Trim leading spaces

This example removes leading spaces from a string:

```sql
SELECT LTRIM('   Redpanda');
```

```sql
+-----------+
| ltrim     |
+-----------+
| Redpanda  |
+-----------+
```

### [](#trim-a-specified-set-of-leading-characters)Trim a specified set of leading characters

This example removes any leading `x` or `y` characters from a string:

```sql
SELECT LTRIM('xyxyRedpanda', 'xy');
```

```sql
+-----------+
| ltrim     |
+-----------+
| Redpanda  |
+-----------+
```