Intl.SegmenterBaseline · Newly available
The Intl.Segmenter API creates a locale-aware text splitter that can separate a string into meaningful graphemes, words, or sentences.
Works in the latest version of every major browser, but older devices may not support it yet. Baseline since Apr 16, 2024.
Browser support
DesktopChrome
1–86Not supported
87+Supportedsince Nov 17, 2020
Current: 155Edge
12–86Not supported
87+Supportedsince Nov 19, 2020
Current: 154Firefox
1–124Not supported
125+Supportedsince Apr 16, 2024
Current: 157Safari
1–14Not supported
14.1+Supportedsince Apr 26, 2021
Current: 27MobileChrome Android
18–86Not supported
87+Supportedsince Nov 17, 2020
Current: 155Firefox Android
4–124Not supported
125+Supportedsince Apr 16, 2024
Current: 157Safari iOS
1–14Not supported
14.5+Supportedsince Apr 26, 2021
Current: 27How to use
Every current browser supports this, but it only became Baseline on Apr 16, 2024. Use it as a progressive enhancement, or keep a fallback if you support older devices.
Example
JS
const segmenter = new Intl.Segmenter("en", { granularity: "word" });
const words = [...segmenter.segment("Hello, world! 👋")]
.filter((s) => s.isWordLike)
.map((s) => s.segment); // ["Hello", "world"]Feature detection
JS · check before using
if ("Segmenter" in Intl || ("prototype" in Intl && "Segmenter" in Intl.prototype)) {
// Intl.Segmenter is available
}Sub-features
Support for each part of the feature (8). The overall table above shows when the whole feature works.
| Sub-feature | Chrome | Edge | Firefox | Safari | Chrome Android | Firefox Android | Safari iOS |
|---|---|---|---|---|---|---|---|
| Intl.Segmenter | 87 | 87 | 125 | 14.1 | 87 | 125 | 14.5 |
| Intl.Segmenter.Segmenter | 87 | 87 | 125 | 14.1 | 87 | 125 | 14.5 |
| Intl.Segmenter.resolvedOptions | 87 | 87 | 125 | 14.1 | 87 | 125 | 14.5 |
| Intl.Segmenter.segment | 87 | 87 | 125 | 14.1 | 87 | 125 | 14.5 |
| Intl.Segmenter.supportedLocalesOf | 87 | 87 | 125 | 14.1 | 87 | 125 | 14.5 |
| Intl.Segments | 87 | 87 | 125 | 14.1 | 87 | 125 | 14.5 |
| Intl.Segments.@@iterator | 87 | 87 | 125 | 14.1 | 87 | 125 | 14.5 |
| Intl.Segments.containing | 87 | 87 | 125 | 14.1 | 87 | 125 | 14.5 |