> For AI agents: the complete documentation index is available at https://massaman.dev/llms.txt, the full documentation bundle is available at https://massaman.dev/llms-full.txt.

# trimStart es-toolkit

Removes whitespace or specified characters from the start of a string.

```typescript
const trimmed = trimStart(str, chars);
```

## Usage

### `trimStart(str, chars?)`

Use `trimStart` when you want to remove unnecessary characters from the beginning of a string. If no specific characters are specified, it removes whitespace characters.

```typescript
import { trimStart } from 'es-toolkit/string';

// Remove default whitespace
trimStart('  hello'); // 'hello'
trimStart('\t\n  hello'); // 'hello'

// Remove specific characters
trimStart('---hello', '-'); // 'hello'
trimStart('000123', '0'); // '123'
trimStart('abcabcabc', 'a'); // 'bcabcabc'
```

If you specify multiple characters as an array, all characters matching any of them will be removed.

```typescript
import { trimStart } from 'es-toolkit/string';

// Specify multiple characters as an array
trimStart('!!@@hello', ['!', '@']); // 'hello'

// Remove numbers and special characters
trimStart('123abc', ['1', '2', '3']); // 'abc'

// Remove characters and whitespace together
trimStart('  __hello', ['_', ' ']); // 'hello'
```

#### Parameters


strstringrequired

The string to remove characters from the start.


charsstring | string[]optional

The characters to remove. Can be a string or an array of characters. Defaults to whitespace characters.

#### Returns

Returns a new string with the specified characters removed from the start.

```typescript
string
```

#### Errors

Throws an error if `chars` is a string with a length other than 1.


Source: es-toolkit

Re-exported verbatim from [`es-toolkit`](https://es-toolkit.dev/reference/string/trimStart.html). Implementation, edge cases, and performance behavior are owned upstream. This page mirrors the documentation at the pinned version; the linked source is authoritative.
