Intl.Segmenter
Browser support
Full support
Browser support
Full support
Available in Chrome from version 87 Chrome
Available in Edge from version 87 Edge
Available in Firefox from version 125 Firefox
Available in Opera from version 73 Opera
Available in Safari from version 14.1 Safari
Available in Chrome Android from version 87 Chrome Android
Available in Firefox for Android from version 125 Firefox for Android
Available in Opera Android from version 62 Opera Android
Available in Safari on iOS from version 14.5 Safari on iOS
Available in Samsung Internet from version 14.0 Samsung Internet
Available in WebView Android from version 87 WebView Android
Available in WebView on iOS from version 14.5 WebView on iOS
Available in Deno from version 1.8 Deno
Available in Node.js from version 16.0.0 Node.js
Input
nb
Output
granularity
{
granularity: "word"
}
[
{
"segment": "This",
"index": 0,
"input": "This is a sentence.",
"isWordLike": true
},
{
"segment": " ",
"index": 4,
"input": "This is a sentence.",
"isWordLike": false
},
{
"segment": "is",
"index": 5,
"input": "This is a sentence.",
"isWordLike": true
},
{
"segment": " ",
"index": 7,
"input": "This is a sentence.",
"isWordLike": false
},
{
"segment": "a",
"index": 8,
"input": "This is a sentence.",
"isWordLike": true
},
{
"segment": " ",
"index": 9,
"input": "This is a sentence.",
"isWordLike": false
},
{
"segment": "sentence",
"index": 10,
"input": "This is a sentence.",
"isWordLike": true
},
{
"segment": ".",
"index": 18,
"input": "This is a sentence.",
"isWordLike": false
}
]
{
granularity: "sentence"
}
[
{
"segment": "This is a sentence.",
"index": 0,
"input": "This is a sentence."
}
]
{
granularity: "grapheme"
}
[
{
"segment": "T",
"index": 0,
"input": "This is a sentence."
},
{
"segment": "h",
"index": 1,
"input": "This is a sentence."
},
{
"segment": "i",
"index": 2,
"input": "This is a sentence."
},
{
"segment": "s",
"index": 3,
"input": "This is a sentence."
},
{
"segment": " ",
"index": 4,
"input": "This is a sentence."
},
{
"segment": "i",
"index": 5,
"input": "This is a sentence."
},
{
"segment": "s",
"index": 6,
"input": "This is a sentence."
},
{
"segment": " ",
"index": 7,
"input": "This is a sentence."
},
{
"segment": "a",
"index": 8,
"input": "This is a sentence."
},
{
"segment": " ",
"index": 9,
"input": "This is a sentence."
},
{
"segment": "s",
"index": 10,
"input": "This is a sentence."
},
{
"segment": "e",
"index": 11,
"input": "This is a sentence."
},
{
"segment": "n",
"index": 12,
"input": "This is a sentence."
},
{
"segment": "t",
"index": 13,
"input": "This is a sentence."
},
{
"segment": "e",
"index": 14,
"input": "This is a sentence."
},
{
"segment": "n",
"index": 15,
"input": "This is a sentence."
},
{
"segment": "c",
"index": 16,
"input": "This is a sentence."
},
{
"segment": "e",
"index": 17,
"input": "This is a sentence."
},
{
"segment": ".",
"index": 18,
"input": "This is a sentence."
}
]
localeMatcher
{
localeMatcher: "best fit"
}
[
{
"segment": "T",
"index": 0,
"input": "This is a sentence."
},
{
"segment": "h",
"index": 1,
"input": "This is a sentence."
},
{
"segment": "i",
"index": 2,
"input": "This is a sentence."
},
{
"segment": "s",
"index": 3,
"input": "This is a sentence."
},
{
"segment": " ",
"index": 4,
"input": "This is a sentence."
},
{
"segment": "i",
"index": 5,
"input": "This is a sentence."
},
{
"segment": "s",
"index": 6,
"input": "This is a sentence."
},
{
"segment": " ",
"index": 7,
"input": "This is a sentence."
},
{
"segment": "a",
"index": 8,
"input": "This is a sentence."
},
{
"segment": " ",
"index": 9,
"input": "This is a sentence."
},
{
"segment": "s",
"index": 10,
"input": "This is a sentence."
},
{
"segment": "e",
"index": 11,
"input": "This is a sentence."
},
{
"segment": "n",
"index": 12,
"input": "This is a sentence."
},
{
"segment": "t",
"index": 13,
"input": "This is a sentence."
},
{
"segment": "e",
"index": 14,
"input": "This is a sentence."
},
{
"segment": "n",
"index": 15,
"input": "This is a sentence."
},
{
"segment": "c",
"index": 16,
"input": "This is a sentence."
},
{
"segment": "e",
"index": 17,
"input": "This is a sentence."
},
{
"segment": ".",
"index": 18,
"input": "This is a sentence."
}
]
{
localeMatcher: "lookup"
}
[
{
"segment": "T",
"index": 0,
"input": "This is a sentence."
},
{
"segment": "h",
"index": 1,
"input": "This is a sentence."
},
{
"segment": "i",
"index": 2,
"input": "This is a sentence."
},
{
"segment": "s",
"index": 3,
"input": "This is a sentence."
},
{
"segment": " ",
"index": 4,
"input": "This is a sentence."
},
{
"segment": "i",
"index": 5,
"input": "This is a sentence."
},
{
"segment": "s",
"index": 6,
"input": "This is a sentence."
},
{
"segment": " ",
"index": 7,
"input": "This is a sentence."
},
{
"segment": "a",
"index": 8,
"input": "This is a sentence."
},
{
"segment": " ",
"index": 9,
"input": "This is a sentence."
},
{
"segment": "s",
"index": 10,
"input": "This is a sentence."
},
{
"segment": "e",
"index": 11,
"input": "This is a sentence."
},
{
"segment": "n",
"index": 12,
"input": "This is a sentence."
},
{
"segment": "t",
"index": 13,
"input": "This is a sentence."
},
{
"segment": "e",
"index": 14,
"input": "This is a sentence."
},
{
"segment": "n",
"index": 15,
"input": "This is a sentence."
},
{
"segment": "c",
"index": 16,
"input": "This is a sentence."
},
{
"segment": "e",
"index": 17,
"input": "This is a sentence."
},
{
"segment": ".",
"index": 18,
"input": "This is a sentence."
}
]