Translator and Language Detector APIs

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 Translator and Language Detector APIs provide functionality to detect the language that text is written in, and to translate text into different languages, via a browser's own internal AI model (which may differ between browsers).

Concepts and usage

Translating a body of text is a common task on today's web. Typical use cases include:

  • On-the-fly translation of an article that isn't available in your language.
  • Translating a user's support requests into a language the support agent understands.
  • Facilitating chats between users that don't speak each other's languages.

Detecting the language of a body of test is an important precursor for successful automated translation, but has other uses beyond direct translation. For example, it allows automatic UI configuration based on user text entry, ranging from updating UI and error strings, to automatically loading appropriate dictionaries for spell checking or curse word detection.

AI is well-suited to facilitating language detection and translation. The Translator and Language Detector APIs provide asynchronous (Promise-based) mechanisms for a website to detect languages and translate text via the browser's own internal AI model. This is useful and efficient because the browser handles the service, rather than the developer having to rely on the user downloading AI models, or host or pay for a cloud-based translation service.

  • Language detection is done via the LanguageDetector interface. A LanguageDetector object instance is created using the LanguageDetector.create() static method, then the detect() instance method is passed the text string to detect the language for.
  • Translation is done via the Translator interface. A Translator object instance is created using the Translator.create() static method, then the translate() instance method is passed the text string to translate.

You can cancel a pending create(), detect(), or translate() operation using an AbortController.

After a LanguageDetector or Translator instance has been created, you can release its assigned resources and stop any further activity by calling its LanguageDetector.destroy()/Translator.destroy() method. You are encouraged to do this after you've finished with the object as it can consume a lot of resources.

See Using the Translator and Language Detector APIs for a walkthrough of how to use the APIs.

Interfaces

LanguageDetector

Contains all the language detection functionality, including checking AI model availability, creating a new LanguageDetector instance, using it to detect a language, and more.

Translator

Contains all the translation functionality, including checking AI model availability, creating a new Translator instance, using it to create a translation, and more.

HTTP headers

Permissions-Policy; the language-detector directive

Controls access to the language detection functionality. Where a policy specifically disallows its use, any attempts to call the LanguageDetector methods will fail with a NotAllowedError DOMException.

Permissions-Policy; the translator directive

Controls access to the translation functionality. Where a policy specifically disallows its use, any attempts to call the Translator methods will fail with a NotAllowedError DOMException.

Security considerations

Creation of LanguageDetector and Translator objects requires that the user has recently interacted with the page (transient user activation is required).

Access to the API is also controlled via language-detector and translator Permissions-Policy directives.

Examples

For a full example, see Using the Translator and Language Detector APIs.

Specifications

Specification
Unknown specification

Browser compatibility

desktop mobile server
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Deno
Node.js
Translator
Experimental
Chrome – Full support
Chrome 138 (Release date: 2025-06-24)
footnote
footnote Availability may be subject to geographical restrictions.
Edge – No support
Edge
footnote No support
Firefox – No support
Firefox
footnote No support
Opera – Full support
Opera 122 (Release date: 2025-09-11)
footnote
footnote Availability may be subject to geographical restrictions.
Safari – No support
Safari
footnote No support
Chrome Android – No support
Chrome Android
footnote No support
Firefox for Android – No support
Firefox for Android
footnote No support
Opera Android – No support
Opera Android
footnote No support
Safari on iOS – No support
Safari on iOS
footnote No support
Samsung Internet – No support
Samsung Internet
footnote No support
WebView Android – No support
WebView Android
footnote No support
WebView on iOS – No support
WebView on iOS
footnote No support
Deno – No support
Deno
footnote No support
Node.js – No support
Node.js
footnote No support
availability() static method
Experimental
Chrome – Full support
Chrome 138 (Release date: 2025-06-24)
footnote
footnote Availability may be subject to geographical restrictions.
Edge – No support
Edge
footnote No support
Firefox – No support
Firefox
footnote No support
Opera – Full support
Opera 122 (Release date: 2025-09-11)
footnote
footnote Availability may be subject to geographical restrictions.
Safari – No support
Safari
footnote No support
Chrome Android – No support
Chrome Android
footnote No support
Firefox for Android – No support
Firefox for Android
footnote No support
Opera Android – No support
Opera Android
footnote No support
Safari on iOS – No support
Safari on iOS
footnote No support
Samsung Internet – No support
Samsung Internet
footnote No support
WebView Android – No support
WebView Android
footnote No support
WebView on iOS – No support
WebView on iOS
footnote No support
Deno – No support
Deno
footnote No support
Node.js – No support
Node.js
footnote No support
create() static method
Experimental
Chrome – Full support
Chrome 138 (Release date: 2025-06-24)
footnote
footnote Availability may be subject to geographical restrictions.
Edge – No support
Edge
footnote No support
Firefox – No support
Firefox
footnote No support
Opera – Full support
Opera 122 (Release date: 2025-09-11)
footnote
footnote Availability may be subject to geographical restrictions.
Safari – No support
Safari
footnote No support
Chrome Android – No support
Chrome Android
footnote No support
Firefox for Android – No support
Firefox for Android
footnote No support
Opera Android – No support
Opera Android
footnote No support
Safari on iOS – No support
Safari on iOS
footnote No support
Samsung Internet – No support
Samsung Internet
footnote No support
WebView Android – No support
WebView Android
footnote No support
WebView on iOS – No support
WebView on iOS
footnote No support
Deno – No support
Deno
footnote No support
Node.js – No support
Node.js
footnote No support
destroy() instance method
Experimental
Chrome – Full support
Chrome 138 (Release date: 2025-06-24)
footnote
footnote Availability may be subject to geographical restrictions.
Edge – No support
Edge
footnote No support
Firefox – No support
Firefox
footnote No support
Opera – Full support
Opera 122 (Release date: 2025-09-11)
footnote
footnote Availability may be subject to geographical restrictions.
Safari – No support
Safari
footnote No support
Chrome Android – No support
Chrome Android
footnote No support
Firefox for Android – No support
Firefox for Android
footnote No support
Opera Android – No support
Opera Android
footnote No support
Safari on iOS – No support
Safari on iOS
footnote No support
Samsung Internet – No support
Samsung Internet
footnote No support
WebView Android – No support
WebView Android
footnote No support
WebView on iOS – No support
WebView on iOS
footnote No support
Deno – No support
Deno
footnote No support
Node.js – No support
Node.js
footnote No support
inputQuota property
Experimental
Chrome – Full support
Chrome 138 (Release date: 2025-06-24)
footnote
footnote Availability may be subject to geographical restrictions.
Edge – No support
Edge
footnote No support
Firefox – No support
Firefox
footnote No support
Opera – Full support
Opera 122 (Release date: 2025-09-11)
footnote
footnote Availability may be subject to geographical restrictions.
Safari – No support
Safari
footnote No support
Chrome Android – No support
Chrome Android
footnote No support
Firefox for Android – No support
Firefox for Android
footnote No support
Opera Android – No support
Opera Android
footnote No support
Safari on iOS – No support
Safari on iOS
footnote No support
Samsung Internet – No support
Samsung Internet
footnote No support
WebView Android – No support
WebView Android
footnote No support
WebView on iOS – No support
WebView on iOS
footnote No support
Deno – No support
Deno
footnote No support
Node.js – No support
Node.js
footnote No support
measureInputUsage() instance method
Experimental
Chrome – Full support
Chrome 138 (Release date: 2025-06-24)
footnote
footnote Availability may be subject to geographical restrictions.
Edge – No support
Edge
footnote No support
Firefox – No support
Firefox
footnote No support
Opera – Full support
Opera 122 (Release date: 2025-09-11)
footnote
footnote Availability may be subject to geographical restrictions.
Safari – No support
Safari
footnote No support
Chrome Android – No support
Chrome Android
footnote No support
Firefox for Android – No support
Firefox for Android
footnote No support
Opera Android – No support
Opera Android
footnote No support
Safari on iOS – No support
Safari on iOS
footnote No support
Samsung Internet – No support
Samsung Internet
footnote No support
WebView Android – No support
WebView Android
footnote No support
WebView on iOS – No support
WebView on iOS
footnote No support
Deno – No support
Deno
footnote No support
Node.js – No support
Node.js
footnote No support
sourceLanguage property
Experimental
Chrome – Full support
Chrome 138 (Release date: 2025-06-24)
footnote
footnote Availability may be subject to geographical restrictions.
Edge – No support
Edge
footnote No support
Firefox – No support
Firefox
footnote No support
Opera – Full support
Opera 122 (Release date: 2025-09-11)
footnote
footnote Availability may be subject to geographical restrictions.
Safari – No support
Safari
footnote No support
Chrome Android – No support
Chrome Android
footnote No support
Firefox for Android – No support
Firefox for Android
footnote No support
Opera Android – No support
Opera Android
footnote No support
Safari on iOS – No support
Safari on iOS
footnote No support
Samsung Internet – No support
Samsung Internet
footnote No support
WebView Android – No support
WebView Android
footnote No support
WebView on iOS – No support
WebView on iOS
footnote No support
Deno – No support
Deno
footnote No support
Node.js – No support
Node.js
footnote No support
targetLanguage property
Experimental
Chrome – Full support
Chrome 138 (Release date: 2025-06-24)
footnote
footnote Availability may be subject to geographical restrictions.
Edge – No support
Edge
footnote No support
Firefox – No support
Firefox
footnote No support
Opera – Full support
Opera 122 (Release date: 2025-09-11)
footnote
footnote Availability may be subject to geographical restrictions.
Safari – No support
Safari
footnote No support
Chrome Android – No support
Chrome Android
footnote No support
Firefox for Android – No support
Firefox for Android
footnote No support
Opera Android – No support
Opera Android
footnote No support
Safari on iOS – No support
Safari on iOS
footnote No support
Samsung Internet – No support
Samsung Internet
footnote No support
WebView Android – No support
WebView Android
footnote No support
WebView on iOS – No support
WebView on iOS
footnote No support
Deno – No support
Deno
footnote No support
Node.js – No support
Node.js
footnote No support
translate() instance method
Experimental
Chrome – Full support
Chrome 138 (Release date: 2025-06-24)
footnote
footnote Availability may be subject to geographical restrictions.
Edge – No support
Edge
footnote No support
Firefox – No support
Firefox
footnote No support
Opera – Full support
Opera 122 (Release date: 2025-09-11)
footnote
footnote Availability may be subject to geographical restrictions.
Safari – No support
Safari
footnote No support
Chrome Android – No support
Chrome Android
footnote No support
Firefox for Android – No support
Firefox for Android
footnote No support
Opera Android – No support
Opera Android
footnote No support
Safari on iOS – No support
Safari on iOS
footnote No support
Samsung Internet – No support
Samsung Internet
footnote No support
WebView Android – No support
WebView Android
footnote No support
WebView on iOS – No support
WebView on iOS
footnote No support
Deno – No support
Deno
footnote No support
Node.js – No support
Node.js
footnote No support
translateStreaming() instance method
Experimental
Chrome – Full support
Chrome 138 (Release date: 2025-06-24)
footnote
footnote Availability may be subject to geographical restrictions.
Edge – No support
Edge
footnote No support
Firefox – No support
Firefox
footnote No support
Opera – Full support
Opera 122 (Release date: 2025-09-11)
footnote
footnote Availability may be subject to geographical restrictions.
Safari – No support
Safari
footnote No support
Chrome Android – No support
Chrome Android
footnote No support
Firefox for Android – No support
Firefox for Android
footnote No support
Opera Android – No support
Opera Android
footnote No support
Safari on iOS – No support
Safari on iOS
footnote No support
Samsung Internet – No support
Samsung Internet
footnote No support
WebView Android – No support
WebView Android
footnote No support
WebView on iOS – No support
WebView on iOS
footnote No support
Deno – No support
Deno
footnote No support
Node.js – No support
Node.js
footnote No support

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support
Experimental. Expect behavior to change in the future.
See implementation notes.

See also