String trimStart() and trimEnd()Baseline · Widely available
The trimStart() and trimEnd() methods of strings return a new string with whitespace removed from the beginning or end of the string.
Supported in all major browsers for at least 30 months — safe to use without fallbacks. Baseline since Jan 15, 2020. Widely available since Jul 15, 2022.
Browser support
DesktopChrome
1–65Not supported
66+Supportedsince Apr 17, 2018
Current: 155Edge
12–18Not supported
79+Supportedsince Jan 15, 2020
Current: 154Firefox
1–60Not supported
61+Supportedsince Jun 26, 2018
Current: 157Safari
1–11.1Not supported
12+Supportedsince Sep 17, 2018
Current: 27MobileChrome Android
18–65Not supported
66+Supportedsince Apr 17, 2018
Current: 155Firefox Android
4–60Not supported
61+Supportedsince Jun 26, 2018
Current: 157Safari iOS
1–11.3Not supported
12+Supportedsince Sep 17, 2018
Current: 27How to use
This feature is Baseline widely available — use it freely, no fallback needed.
Example
Full syntax and examples are on MDN: trimEnd.
Feature detection
JS · check before using
if ("trimEnd" in String || ("prototype" in String && "trimEnd" in String.prototype)) {
// String.trimEnd is available
}Documentation (MDN)
Specification
Sub-features
Support for each part of the feature (2). The overall table above shows when the whole feature works.
| Sub-feature | Chrome | Edge | Firefox | Safari | Chrome Android | Firefox Android | Safari iOS |
|---|---|---|---|---|---|---|---|
| String.trimEnd | 66 | 79 | 61 | 12 | 66 | 61 | 12 |
| String.trimStart | 66 | 79 | 61 | 12 | 66 | 61 | 12 |