String.toWellFormed() Benchmark

The String.prototype.toWellFormed() method returns a string where all lone surrogates are replaced with the Unicode replacement character U+FFFD. This ensures that the string is well-formed UTF-16.

This page benchmarks the toWellFormed() method that landed in browsers in 2024.

This new function is fast and ensures string well-formedness.

const wellFormed = str.toWellFormed();      // well-formed string

To see how fast the function is in your browser, hit the button.