coderef

String replaceAll()Baseline · Widely available

The replaceAll() method of strings returns a new string where all matches of a pattern (a string or regular expression) have been substituted with a replacement string.

Supported in all major browsers for at least 30 months — safe to use without fallbacks. Baseline since Aug 27, 2020. Widely available since Feb 27, 2023.

Browser support

DesktopChrome
1–84Not supported
85+Supportedsince Aug 25, 2020
Current: 155
Edge
12–84Not supported
85+Supportedsince Aug 27, 2020
Current: 154
Firefox
1–76Not supported
77+Supportedsince Jun 2, 2020
Current: 157
Safari
1–13Not supported
13.1+Supportedsince Mar 24, 2020
Current: 27
MobileChrome Android
18–84Not supported
85+Supportedsince Aug 25, 2020
Current: 155
Firefox Android
4–68Not supported
79+Supportedsince Jul 28, 2020
Current: 157
Safari iOS
1–13Not supported
13.4+Supportedsince Mar 24, 2020
Current: 27

How to use

This feature is Baseline widely available — use it freely, no fallback needed.

Example

Full syntax and examples are on MDN: replaceAll.

Feature detection

JS · check before using
if ("replaceAll" in String || ("prototype" in String && "replaceAll" in String.prototype)) {
  // String.replaceAll is available
}

Documentation (MDN)

Specification