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 interface of the Translator and Language Detector APIs contains all the associated translation functionality, including checking AI model availability, creating a new Translator instance, using it to create a translation, and more.
inputQuota Read only Experimental
The input quota available to the browser for generating translations.
sourceLanguage Read only Experimental
The expected language of the input text to be translated.
targetLanguage Read only Experimental
The language that the input text will be translated into.
availability() Experimental
Returns an enumerated value that indicates the availability of the AI model for the given Translator configuration.
create() Experimental
Creates a new Translator instance from which to generate translations.
destroy() Experimental
Destroys the Translator instance it is called on.
measureInputUsage() Experimental
Reports how much input quota would be used by a translation operation for a given text input.
translate() Experimental
Returns a string containing a translation of the input string.
translateStreaming() Experimental
Generates a translation of the input string as a ReadableStream.
See Using the Translator and Language Detector APIs for a complete example.
Translator instanceconst translator = await Translator.create({
sourceLanguage: "en",
targetLanguage: "ja",
});
const translation = await translator.translate(myTextString); console.log(translation);
const stream = translator.translateStreaming(myTextString);
let translation = "";
for await (const chunk of stream) {
translation += chunk;
}
console.log("Stream complete");
console.log(translation);
| Specification |
|---|
| Translator and Language Detector APIs> # translator> |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
Translator |
138Availability may be subject to geographical restrictions. |
No | 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. |
No | 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. |
No | No | 122Availability may be subject to geographical restrictions. |
No | No | No | No | No | No | No | No |
destroy |
138Availability may be subject to geographical restrictions. |
No | No | 122Availability may be subject to geographical restrictions. |
No | No | No | No | No | No | No | No |
inputQuota |
138Availability may be subject to geographical restrictions. |
No | No | 122Availability may be subject to geographical restrictions. |
No | No | No | No | No | No | No | No |
measureInputUsage |
138Availability may be subject to geographical restrictions. |
No | No | 122Availability may be subject to geographical restrictions. |
No | No | No | No | No | No | No | No |
sourceLanguage |
138Availability may be subject to geographical restrictions. |
No | No | 122Availability may be subject to geographical restrictions. |
No | No | No | No | No | No | No | No |
targetLanguage |
138Availability may be subject to geographical restrictions. |
No | No | 122Availability may be subject to geographical restrictions. |
No | No | No | No | No | No | No | No |
translate |
138Availability may be subject to geographical restrictions. |
No | No | 122Availability may be subject to geographical restrictions. |
No | No | No | No | No | No | No | No |
translateStreaming |
138Availability may be subject to geographical restrictions. |
No | No | 122Availability may be subject to geographical restrictions. |
No | No | No | No | No | No | No | No |
© 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/Translator