W3cubDocs

/Web APIs

Summarizer: summarize() method

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.

The summarize() method of the Summarizer interface generates a new summary string.

Syntax

summarize(input)
summarize(input, options)

Parameters

input

A string representing the text to be summarized.

options Optional

An object specifying configuration options for the summarize() operation. Possible values include:

context

A string describing the context the input text is being used in, which helps the Summarizer generate a more suitable summary.

signal

An AbortSignal object instance, which allows the summarize() operation to be aborted via the associated AbortController.

Return value

A Promise that fulfills with a string containing the generated summary.

Exceptions

InvalidStateError DOMException

Thrown if the current Document is not active.

NotAllowedError DOMException

Thrown if usage of the Summarizer API is blocked by a summarizer Permissions-Policy.

NotReadableError DOMException

Thrown if the output summary was filtered by the user agent, for example because it was detected to be harmful, inaccurate, or nonsensical.

NotSupportedError DOMException

Thrown if the provided context is not in language the Summarizer supports.

QuotaExceededError

Thrown if the summarize operation exceeds the available inputQuota.

UnknownError DOMException

Thrown if the summarize() call failed for any other reason, or a reason the user agent did not wish to disclose.

Examples

>

Basic summarize() usage

const summarizer = await Summarizer.create({
  sharedContext:
    "A general summary to help a user decide if the text is worth reading",
  type: "tldr",
  length: "short",
});

const summary = await summarizer.summarize(myTextString);
console.log(summary);

Specifications

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Opera Safari Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet WebView Android WebView on iOS
summarize
138Availability may be subject to geographical restrictions.
138 No
122Availability may be subject to geographical restrictions.
No No No No No No No No

See also

© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/Summarizer/summarize