Favorites

JavaScript String.prototype.trimStart() Method

☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee
String.prototype.trimStart()
JavaScript String Instance methodThis method is supported by all modern browsers.
Updated 28th November 2026

The trimStart() method removes white space from the start of a string only.

Description

The trimStart() method removes leading white space and leaves the end of the string alone. It is also available under its older name, trimLeft().

It removes the same characters as trim(): spaces, tabs, non-breaking spaces, line breaks and other Unicode white space. The original string isn't changed.

It's useful for cleaning up indented text, such as lines of a template literal or code being processed, where the end of each line should stay as it is. To remove only specific characters, such as leading zeros, use a regular expression like str.replace(/^0+/, '').

Syntax

string.trimStart()

Return Value

A new string with white space removed from the start.

Example

console.log('[' + '   indented text  '.trimStart() + ']');

Browser Support

The following information will show you the current browser support for the String.prototype.trimStart() method. Hover over a browser icon to see the version that first introduced support for this method.

This method is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported
☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee