| CARVIEW |
Select Language
HTTP/2 302
x-cloud-trace-context: 5115a2a5f2a5f6cae2babf81ae53ee40
location: /en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter/segment
via: 1.1 google, 1.1 varnish, 1.1 varnish, 1.1 varnish, 1.1 varnish
accept-ranges: bytes
cache-control: no-store
server: Google Frontend
content-type: text/plain; charset=utf-8
date: Sat, 27 Dec 2025 06:12:58 GMT
x-served-by: cache-bfi-krnt7300033-BFI, cache-bfi-krnt7300048-BFI, cache-sin-wsat1880095-SIN, cache-bom-vanm7210088-BOM
x-cache: MISS, MISS, MISS, MISS
x-cache-hits: 0, 0, 0, 0
x-timer: S1766815978.204295,VS0,VE295
vary: Accept
content-length: 96
HTTP/2 200
x-content-type-options: nosniff
cache-control: public, max-age=3600
via: 1.1 google, 1.1 varnish, 1.1 varnish, 1.1 varnish, 1.1 varnish
x-cloud-trace-context: 1ba4cca66e2d97986e45b23f2fc357c1
server: Google Frontend
last-modified: Sat, 27 Dec 2025 01:06:29 GMT
referrer-policy: strict-origin-when-cross-origin
origin-trial: AxVILwizhbMjxFeHOn1P3R8niO1RJY/smaK4B4d1rLzc1gTaxtXMSaTi+FoigYgCw40uFRDwFcEAeqDR+vVLOW4AAABfeyJvcmlnaW4iOiJodHRwczovL2RldmVsb3Blci5tb3ppbGxhLm9yZyIsImZlYXR1cmUiOiJQcml2YXRlQXR0cmlidXRpb25WMiIsImV4cGlyeSI6MTc0MjA3OTYwMH0=
content-type: text/html
etag: "ab860aa4e6a61c1e3d0ec7f99acdb5e9"
strict-transport-security: max-age=63072000
expires: Sat, 27 Dec 2025 07:07:36 GMT
x-goog-meta-goog-reserved-file-mtime: 1766796650
x-goog-storage-class: STANDARD
x-frame-options: DENY
x-goog-metageneration: 1
x-goog-hash: crc32c=zNACDQ==, md5=q4YKpOamHB49Dsf5ms216Q==
x-guploader-uploadid: AHVrFxOl856XUFsd-x0doEOL00bznGVxlKVWHR-i6adPp6KeDwsdR9psMNWulc_ENyGhIMsJ
x-goog-stored-content-encoding: identity
content-security-policy: default-src 'self'; script-src 'report-sample' 'self' 'wasm-unsafe-eval' https://www.google-analytics.com/analytics.js https://*.googletagmanager.com assets.codepen.io production-assets.codepen.io https://js.stripe.com 'sha256-XNBp89FG76amD8BqrJzyflxOF9PaWPqPqvJfKZPCv7M=' 'sha256-YCNoU9DNiinACbd8n6UPyB/8vj0kXvhkOni9/06SuYw=' 'sha256-PZjP7OR6mBEtnvXIZfCZ5PuOlxoDF1LDZL8aj8c42rw='; script-src-elem 'report-sample' 'self' 'wasm-unsafe-eval' https://www.google-analytics.com/analytics.js https://*.googletagmanager.com assets.codepen.io production-assets.codepen.io https://js.stripe.com 'sha256-XNBp89FG76amD8BqrJzyflxOF9PaWPqPqvJfKZPCv7M=' 'sha256-YCNoU9DNiinACbd8n6UPyB/8vj0kXvhkOni9/06SuYw=' 'sha256-PZjP7OR6mBEtnvXIZfCZ5PuOlxoDF1LDZL8aj8c42rw='; style-src 'report-sample' 'self' 'unsafe-inline'; object-src 'none'; base-uri 'self'; connect-src 'self' developer.allizom.org bcd.developer.allizom.org bcd.developer.mozilla.org updates.developer.allizom.org updates.developer.mozilla.org https://*.google-analytics.com https://*.analytics.google.com https://*.googletagmanager.com https://incoming.telemetry.mozilla.org https://observatory-api.mdn.allizom.net https://observatory-api.mdn.mozilla.net https://api.github.com/search/issues stats.g.doubleclick.net https://api.stripe.com; font-src 'self'; frame-src 'self' mdn.github.io *.mdnplay.dev *.mdnyalp.dev *.play.test.mdn.allizom.net https://v2.scrimba.com https://scrimba.com jsfiddle.net www.youtube-nocookie.com codepen.io survey.alchemer.com https://js.stripe.com; img-src 'self' data: *.githubusercontent.com *.googleusercontent.com *.gravatar.com mozillausercontent.com firefoxusercontent.com profile.stage.mozaws.net profile.accounts.firefox.com developer.mozilla.org mdn.dev wikipedia.org upload.wikimedia.org https://mdn.github.io/shared-assets/ https://mdn.dev/ https://*.google-analytics.com https://*.googletagmanager.com www.gstatic.com; manifest-src 'self'; media-src 'self' archive.org videos.cdn.mozilla.net https://mdn.github.io/shared-assets/; child-src 'self'; worker-src 'self';
x-goog-generation: 1766797589502058
x-goog-stored-content-length: 148540
content-encoding: gzip
accept-ranges: bytes
age: 322
date: Sat, 27 Dec 2025 06:12:58 GMT
x-served-by: cache-bfi-krnt7300040-BFI, cache-bfi-krnt7300081-BFI, cache-sin-wsat1880052-SIN, cache-bom-vanm7210088-BOM
x-cache: MISS, HIT, MISS, MISS
x-cache-hits: 0, 1, 0, 0
x-timer: S1766815979.512389,VS0,VE239
vary: Accept-Encoding
content-length: 19626
Intl.Segmenter.prototype.segment() - JavaScript | MDN
Toggle sidebar
>
Intl.Segmenter.prototype.segment()
Baseline
2024
Newly available
Since April 2024, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.
The segment() method of Intl.Segmenter instances segments a string according to the locale and granularity of this Intl.Segmenter object.
Try it
const string1 = "Que ma joie demeure";
const segmenterFrGrapheme = new Intl.Segmenter("fr", {
granularity: "grapheme",
});
const graphemeSegments = segmenterFrGrapheme.segment(string1);
console.log(Array.from(graphemeSegments)[0]);
// Expected output:
// Object {segment: 'Q', index: 0, input: 'Que ma joie demeure'}
Syntax
js
segment(input)
Parameters
input-
The text to be segmented as a string.
Return value
A new iterable Segments object containing the segments of the input string, using the segmenter's locale and granularity.
Examples
js
// Create a locale-specific word segmenter
const segmenter = new Intl.Segmenter("fr", { granularity: "word" });
// Use it to get an iterator over the segments of a string
const input = "Moi ? N'est-ce pas ?";
const segments = segmenter.segment(input);
// Use that for segmentation
for (const { segment, index, isWordLike } of segments) {
console.log(
"segment at code units [%d, %d]: «%s»%s",
index,
index + segment.length,
segment,
isWordLike ? " (word-like)" : "",
);
}
// segment at code units [0, 3]: «Moi» (word-like)
// segment at code units [3, 4]: « »
// segment at code units [4, 5]: «?»
// segment at code units [5, 6]: « »
// segment at code units [6, 11]: «N'est» (word-like)
// segment at code units [11, 12]: «-»
// segment at code units [12, 14]: «ce» (word-like)
// segment at code units [14, 15]: « »
// segment at code units [15, 18]: «pas» (word-like)
// segment at code units [18, 19]: « »
// segment at code units [19, 20]: «?»
Specifications
| Specification |
|---|
| ECMAScript® 2026 Internationalization API Specification> # sec-intl.segmenter.prototype.segment> |