Removes leading whitespace — or a custom set of characters — from the start of a string. Trailing characters stay. Part of Lodash String (stable since 4.0.0 — not deprecated; _.trimLeft is an alias).
Pass the string and options shown below. Check the return type before you chain another helper.
Syntax
Call _.trimStart. Start with this line.
Lodash
_.trimStart([string=''], [chars=whitespace])
Call
What it does
_.trimStart([string=''], [chars=whitespace])
Primary signature.
_.trimStart(string)
Transform or inspect a string.
Prefer import trimStart from "lodash/trimStart" when you want a smaller bundle.
Library declarations
Lodash
_.trimStart([string=''], [chars=whitespace])
Parameters
Parameter
Description
string
Optional. Value to trim (default '')
chars
Optional. Characters to strip from the start (default: whitespace)
Return Value
Return Value
Description
*
New string with leading chars removed
Lodash Examples
Example 1 — Official: Trim Leading Whitespace
Spaces on the left go away; spaces on the right stay.
_.trimStart is a Lodash String helper available since 4.0.0 (_.trimLeft alias). It runs anywhere Lodash runs — modern browsers (via CDN or bundle) and Node.js / Bun / Deno with npm install lodash.
✓ Stable · Lodash 4.x
_.trimStart()
Available in [email protected] full builds and the lodash/trimStart modular import. Works in evergreen browsers and current Node LTS when Lodash is installed.
100%With Lodash 4.x
Google ChromeSupported · Desktop & Mobile
Full support
Mozilla FirefoxSupported · Desktop & Mobile
Full support
Apple SafariSupported · macOS & iOS
Full support
Microsoft EdgeSupported · Chromium
Full support
Internet ExplorerNo native support · Use a polyfill
Polyfill
OperaSupported · Modern versions
Full support
Samsung InternetSupported · Android
Full support
BunSupported · JavaScript runtime
Supported
DenoSupported · JavaScript runtime
Supported
Node.jsSupported · Server runtime
Supported
Android WebViewSupported · Modern WebView
Full support
_.trimStartSince 4.0.0
Bottom line: Safe for production once Lodash is on the page. Prefer import trimStart from "lodash/trimStart" for smaller builds. Native String#trimStart is fine for whitespace-only cases without Lodash.
Frequently Asked Questions
_.trimStart([string=''], [chars=whitespace]) removes leading whitespace or specified characters from the start only. Official: _.trimStart(' abc ') → 'abc '.
No. Trailing characters — including trailing whitespace — are preserved.
It is a set of characters to strip from the start — not an exact substring. _.trimStart('-_-abc-_-', '_-') removes any mix of '_' and '-' from the left.
_.trim cleans both ends. _.trimEnd cleans only the end. _.trimStart cleans only the start.
Yes. _.trimLeft is an alias of _.trimStart in Lodash 4.x. Prefer _.trimStart in new code.
Use import trimStart from "lodash/trimStart" or require("lodash/trimStart"). Full build: import _ from "lodash" then _.trimStart.