coderef

String isWellFormed() and toWellFormed()Baseline · Widely available

The isWellFormed() method of strings returns a boolean indicating if the string contains any Unicode lone surrogates. The toWellFormed() method returns a new string where all lone surrogates are replaced by the Unicode replacement character.

Supported in all major browsers for at least 30 months — safe to use without fallbacks. Baseline since Oct 24, 2023. Widely available since Apr 24, 2026.

Browser support

DesktopChrome
1–110Not supported
111+Supportedsince Mar 7, 2023
Current: 155
Edge
12–110Not supported
111+Supportedsince Mar 13, 2023
Current: 154
Firefox
1–118Not supported
119+Supportedsince Oct 24, 2023
Current: 157
Safari
1–16.3Not supported
16.4+Supportedsince Mar 27, 2023
Current: 27
MobileChrome Android
18–110Not supported
111+Supportedsince Mar 7, 2023
Current: 155
Firefox Android
4–118Not supported
119+Supportedsince Oct 24, 2023
Current: 157
Safari iOS
1–16.3Not supported
16.4+Supportedsince Mar 27, 2023
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: isWellFormed.

Feature detection

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

Sub-features

Support for each part of the feature (2). The overall table above shows when the whole feature works.

Sub-featureChromeEdgeFirefoxSafariChrome AndroidFirefox AndroidSafari iOS
String.isWellFormed11111111916.411111916.4
String.toWellFormed11111111916.411111916.4