W3cubDocs

/Web APIs

Summarizer

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 Summarizer interface of the Summarizer API contains all the functionality for this API, including checking AI model availability, creating a new Summarizer instance, using it to generate a new summary, and more.

Instance properties

expectedContextLanguages Read only Experimental

The languages the context strings should be written in.

expectedInputLanguages Read only Experimental

The languages the Summarizer should support.

format Read only Experimental

The text format summaries will be returned in.

inputQuota Read only Experimental

The input quota available to the browser for generating summaries.

length Read only Experimental

The relative length of the generated summaries.

outputLanguage Read only Experimental

The language the summary should be generated in.

sharedContext Read only Experimental

A text string describing the context the pieces of text to summarize are being used in, which helps the Summarizer generate more suitable summaries.

type Read only Experimental

The type of summary that will generated by the Summarizer.

Static methods

availability() Experimental

Returns an enumerated value that indicates whether the browser AI model supports a given Summarizer configuration.

create() Experimental

Creates a new Summarizer instance from which to generate summaries.

Instance methods

destroy() Experimental

Destroys the Summarizer instance it is called on.

measureInputUsage() Experimental

Reports how much input quota would be used by a summarize operation for a given text input.

summarize() Experimental

Generates a new summary string.

summarizeStreaming() Experimental

Generates a new summary as a ReadableStream.

Examples

See Using the Summarizer API for a complete example.

Creating a Summarizer instance

const summarizer = await Summarizer.create({
  sharedContext:
    "A general summary to help a user decide if the text is worth reading",
  type: "tldr",
  length: "short",
  format: "markdown",
  expectedInputLanguages: ["en-US"],
  outputLanguage: "en-US",
});

Generating a summary

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

Generating a summary stream

const stream = summarizer.summarizeStreaming(myTextString);
let summary = "";

for await (const chunk of stream) {
  summary += chunk;
}

console.log("Stream complete");
summaryOutput.textContent = 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
Summarizer
138Availability may be subject to geographical restrictions.
138 No
122Availability may be subject to geographical restrictions.
No No No No No No No No
availability_static
138Availability may be subject to geographical restrictions.
138 No
122Availability may be subject to geographical restrictions.
No No No No No No No No
create_static
138Availability may be subject to geographical restrictions.
138 No
122Availability may be subject to geographical restrictions.
No No No No No No No No
destroy
138Availability may be subject to geographical restrictions.
138 No
122Availability may be subject to geographical restrictions.
No No No No No No No No
expectedContextLanguages
138Availability may be subject to geographical restrictions.
138 No
122Availability may be subject to geographical restrictions.
No No No No No No No No
expectedInputLanguages
138Availability may be subject to geographical restrictions.
138 No
122Availability may be subject to geographical restrictions.
No No No No No No No No
format
138Availability may be subject to geographical restrictions.
138 No
122Availability may be subject to geographical restrictions.
No No No No No No No No
inputQuota
138Availability may be subject to geographical restrictions.
138 No
122Availability may be subject to geographical restrictions.
No No No No No No No No
length
138Availability may be subject to geographical restrictions.
138 No
122Availability may be subject to geographical restrictions.
No No No No No No No No
measureInputUsage
138Availability may be subject to geographical restrictions.
138 No
122Availability may be subject to geographical restrictions.
No No No No No No No No
outputLanguage
138Availability may be subject to geographical restrictions.
138 No
122Availability may be subject to geographical restrictions.
No No No No No No No No
sharedContext
138Availability may be subject to geographical restrictions.
138 No
122Availability may be subject to geographical restrictions.
No No No No No No No No
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
summarizeStreaming
138Availability may be subject to geographical restrictions.
138 No
122Availability may be subject to geographical restrictions.
No No No No No No No No
type
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