← Chrome 161 reference · All APIs
v161 · web ai · android · enabled by default
Translator API on Android
Brings the on-device Translator Web API to Chrome for Android (including Chrome Custom Tabs) in Chrome 161, matching the desktop WebIDL surface shipped in Chrome 138 while introducing mobile-specific runtime guardrails — a per-origin isolated_app utility process, a 2-service concurrency cap, 1-minute idle model unloading, a 256 KiB per-call input limit, storage and metered-network availability gates, and Android support for the TranslatorAPIAllowed enterprise policy.
at a glance
| Shipped in | Chrome 161 on Android (including Chrome Custom Tabs) — filed under “Enabled by default” in the milestone=161 listing; Android WebView and iOS are null (not supported) in the ChromeStatus API record. Desktop Chrome shipped separately in M138. |
|---|---|
| Runtime flag & policy | Finch feature TranslationAPI (in runtime_enabled_features.json5; Android constants in components/on_device_translation/features.cc). Administrators can disable the API and block model downloads via TranslatorAPIAllowed on Android. |
| Specification | Web Machine Learning CG — Translator and Language Detector APIs (Community Group Draft); supporting types in Writing Assistance APIs |
| Explainer & docs | webmachinelearning/translation-api explainer · Chrome for Developers guide · MDN Translator (desktop) |
| Intent & bug | blink-dev Intent thread · crbug 428227642 |
| Web platform tests | external/wpt/ai/translator/ plus Android unit tests and mock-engine browser tests (known WPT flakiness bugs: crbug 479913865, crbug 510552929, crbug 525227294) |
| ChromeStatus | 5106126157905920 — Translator API on Android |
why it exists
Mobile web applications previously had to send user text to cloud translation endpoints or bundle heavy client-side ML weights, adding latency, data usage, and privacy exposure. Shipping Translator on Chrome for Android (including Chrome Custom Tabs) pairs with the Language Detector API on Android (M157) so mobile sites can detect and translate text locally with offline support once language packs are cached, while Chromium enforces strict mobile memory, storage, input-size, and metered-network guardrails so on-device translation does not destabilize phones.
Syntax & WebIDL
Chrome for Android exposes the identical Translator WebIDL surface already shipped on desktop Chrome 138:
// Verbatim from Web Machine Learning CG Translator API specification
[Exposed=Window, SecureContext]
interface Translator {
static Promise<Translator> create(TranslatorCreateOptions options);
static Promise<Availability> availability(TranslatorCreateCoreOptions options);
Promise<DOMString> translate(
DOMString input,
optional TranslatorTranslateOptions options = {}
);
ReadableStream translateStreaming(
DOMString input,
optional TranslatorTranslateOptions options = {}
);
readonly attribute DOMString sourceLanguage;
readonly attribute DOMString targetLanguage;
Promise<double> measureInputUsage(
DOMString input,
optional TranslatorTranslateOptions options = {}
);
readonly attribute unrestricted double inputQuota;
};
Translator includes DestroyableModel;
dictionary TranslatorCreateCoreOptions {
required DOMString sourceLanguage;
required DOMString targetLanguage;
};
dictionary TranslatorCreateOptions : TranslatorCreateCoreOptions {
AbortSignal signal;
CreateMonitorCallback monitor;
};
dictionary TranslatorTranslateOptions {
AbortSignal signal;
};
// Supporting types from Writing Assistance APIs
enum Availability {
"unavailable",
"downloadable",
"downloading",
"available"
};
[Exposed=Window, SecureContext]
interface CreateMonitor : EventTarget {
attribute EventHandler ondownloadprogress;
};
callback CreateMonitorCallback = undefined (CreateMonitor monitor);
interface mixin DestroyableModel {
undefined destroy();
};
In Blink’s translator.idl, Translator is exposed on Window via TranslationAPI (and on Worker only when the separate experimental TranslationAPIForWorkers flag is enabled). This reference documents all five parts of the Chrome 161 Android contract: Translator.availability(), Translator.create() & downloads, translate() & translateStreaming(), quota, metadata & destroy(), and Android runtime guardrails & enterprise policy.
translator.idl.
Translator.availability(options)
Inputs. Requires a TranslatorCreateCoreOptions dictionary containing BCP 47 Unicode locale identifiers for sourceLanguage and targetLanguage (canonicalized in Blink via ValidateAndCanonicalizeUnicodeLocaleId).
Outputs. Returns a Promise<Availability> resolving to one of four enum values without triggering a model download:
| Value | Meaning on Android |
|---|---|
"available" | The bundled translation library and required language pack(s) are already on-device and ready for immediate Translator.create(). |
"downloadable" | The language pair is supported, device storage and network checks pass, and calling Translator.create() (with user activation) will download the language pack(s) via Component Updater. |
"downloading" | Required language pack(s) are currently downloading in the background. |
"unavailable" | Returned when the language pair is unsupported, the translator permissions policy is blocked, TranslatorAPIAllowed enterprise policy disables the API, or Android storage, device-resource, or metered-network guardrails block downloading/running the model (without revealing whether packs are installed). |
translator.cc; ChromeStatus 5106126157905920.
Translator.create(options) & download monitoring
Inputs. Accepts TranslatorCreateOptions: required sourceLanguage and targetLanguage strings, optional signal (AbortSignal to cancel download/creation and bind session abort), and optional monitor callback receiving a CreateMonitor whose downloadprogress event reports download progress (e.loaded normalized from 0 to 1).
Outputs & behavior. Returns a Promise<Translator>. On Android, the translation library is bundled with Chrome while language packs download on demand via Chromium’s Component Updater (CRX3- and SHA-256-verified) after sticky user activation. Always check Translator.availability() first and invoke Translator.create() inside a user gesture when a download is required.
create_translator_client.cc; ChromeStatus ergonomics & security notes.
translate(input, options) & translateStreaming(input, options)
Inputs. Both instance methods take a DOMString input (unmatched UTF-16 surrogates are replaced before IPC in Blink) and optional { signal } (TranslatorTranslateOptions).
Outputs. translate() returns a Promise<DOMString> resolving to the full translated string. translateStreaming() synchronously returns a ReadableStream of string chunks suitable for progressive UI rendering of longer passages. On Android, single-call inputs exceeding the 256 KiB engine budget (kTranslationAPIMaxInputSizeBytes) fail with a standard spec-defined error (QuotaExceededError), so callers should chunk large documents (for example by paragraph or sentence) before translating.
translator.cc; Chromium features.cc.
Quota, metadata, destroy() & lifecycle
Attributes & methods.
sourceLanguage/targetLanguage(readonlyDOMString): canonicalized BCP 47 tags for this instance.inputQuota(readonlyunrestricted double) &measureInputUsage(input, options)(Promise<double>): spec-defined quota inspection surface. Note that in Chromium’s currenttranslator.cc,inputQuotareturnsInfinitywhile Android enforces its hard 256 KiB per-call byte budget in the translation service — do not rely solely oninputQuotato skip chunking orQuotaExceededErrorhandling on Android.destroy()(fromDestroyableModel): releases the Mojo remote and aborts in-flight calls on thatTranslatorinstance. Callingdestroy()promptly is especially valuable on Android where each loaded language pair consumes ~79–84 MiB and at most 2 per-origin service processes can run concurrently.
Lifecycle & idle unloading. On Android, Chromium automatically unloads idle translation models after 1 minute (kTranslationAPIModelIdleUnloadTimeout) and shuts down idle utility services after 1 minute (kTranslationAPIServiceIdleTimeout). Applications keeping a Translator reference across long pauses should expect transparent reload latency or recreate the translator if the service was reclaimed.
translator.cc; Chromium features.cc; ChromeStatus 5106126157905920.
Android runtime guardrails & enterprise policy
Chrome for Android enforces stricter mobile resource limits than desktop Chrome, verified directly in components/on_device_translation/features.cc and ChromeStatus 5106126157905920:
| Guardrail / FeatureParam | Chrome for Android (M161) | Chrome Desktop (M138+) | Developer impact |
|---|---|---|---|
TranslationAPIMaxServiceCount | 2 concurrent service processes | 10 concurrent service processes | Each per-origin isolated_app utility process holds ~79–84 MiB per loaded language pair; call destroy() when switching pairs. |
TranslationAPIModelIdleUnloadTimeout | 1 minute | Disabled (0) | Idle models unload automatically after 60s to reclaim mobile RAM. |
TranslationAPIMaxInputSizeBytes | 256 KiB (~40,000 English words) | 0 (unbounded) | Oversized single calls reject with QuotaExceededError; chunk large inputs. |
TranslationAPIServiceIdleTimeout | 1 minute | 1 minute | Idle utility process exits after 60s. |
| Storage & metered-network checks | Enforced before pack download | Desktop disk-space checks | Insufficient storage or metered-network restrictions report "unavailable" without leaking installed packs. |
| Chrome Custom Tabs | Supported | N/A | Works inside Android Custom Tabs as well as standard Chrome tabs. |
TranslatorAPIAllowed policy | Supported on Android | Supported on desktop | When disabled by enterprise policy, API is unavailable and model downloads are prevented. |
components/on_device_translation/features.cc; ChromeStatus 5106126157905920; Chrome Enterprise TranslatorAPIAllowed.
Errors & failure modes
| Error | When it occurs | Recovery |
|---|---|---|
TypeError / RangeError | Missing required sourceLanguage / targetLanguage, or invalid BCP 47 language tag rejected by Unicode locale canonicalization. | Validate and normalize BCP 47 language codes before calling. |
NotAllowedError (DOMException) | The translator permissions policy is disallowed (e.g., cross-origin iframe without allow="translator"), or Translator.create() requires a download without user activation. | Add allow="translator" where appropriate and trigger Translator.create() inside a user gesture. |
NotSupportedError (DOMException) | Unsupported language pair, disabled by TranslatorAPIAllowed policy, or device/storage/metered-network checks prevent creation. | Check Translator.availability() first and fall back to server/UI alternative. |
QuotaExceededError (DOMException) | Input exceeds Android’s 256 KiB per-call input budget (TranslationAPIMaxInputSizeBytes) or concurrency/resource quota is exceeded. | Split text into smaller UTF-8 chunks (≤ 256 KiB, ideally a few KiB per call) and call destroy() on unused translators. |
AbortError (DOMException) | AbortSignal passed to create(), translate(), or translateStreaming() aborted, or destroy() was called mid-flight. | Handle cancellation cleanly and avoid retrying aborted user actions. |
translator.cc & create_translator_client.cc.
Context, exposure & permissions policy
Translator requires a SecureContext (HTTPS or localhost) and is exposed on Window (including top-level pages, Android Chrome Custom Tabs, and iframes granted the translator permissions policy — default allowlist 'self'). Cross-origin iframes must opt in via allow="translator" and an appropriate Permissions-Policy: translator=(...) response header. Exposure in Web Workers is not enabled by default (gated by TranslationAPIForWorkers). Android WebView does not expose the API.
translator.idl; ChromeStatus 5106126157905920.
Examples
Translator.availability() without auto-downloading models. Sibling interactive concept demos (all verified 200): download on a constrained device, memory and input limits, failure and policy gates, and offline chat composer.Source: chrome-platform-showcaseAndroid-safe availability check, user-activated creation, chunked translation, and cleanup
// Stay well below Android's 256 KiB TranslationAPIMaxInputSizeBytes cap.
const MAX_ANDROID_CHUNK_BYTES = 16 * 1024;
const encoder = new TextEncoder();
async function translateSafely(text, sourceLanguage, targetLanguage, onProgress) {
if (typeof Translator === "undefined") {
throw new Error("Translator API is not supported in this browser");
}
const pair = { sourceLanguage, targetLanguage };
const state = await Translator.availability(pair);
if (state === "unavailable") {
// Could be unsupported pair, low storage, metered network, or TranslatorAPIAllowed policy.
throw new Error(`Translation unavailable for ${sourceLanguage} -> ${targetLanguage}`);
}
const controller = new AbortController();
const translator = await Translator.create({
...pair,
signal: controller.signal,
monitor(m) {
m.addEventListener("downloadprogress", (e) => {
onProgress?.(Math.round(e.loaded * 100));
});
},
});
try {
// Chunk input to avoid QuotaExceededError on Android's 256 KiB input budget.
if (encoder.encode(text).byteLength <= MAX_ANDROID_CHUNK_BYTES) {
return await translator.translate(text, { signal: controller.signal });
}
const paragraphs = text.split(/\n{2,}/);
const out = [];
for (const part of paragraphs) {
out.push(await translator.translate(part, { signal: controller.signal }));
}
return out.join("\n\n");
} finally {
// Release the ~79-84 MiB language pair promptly under Android's TranslationAPIMaxServiceCount (2).
translator.destroy();
}
}
Source: Translator API spec; Chromium features.cc.
Streaming translation output with translateStreaming()
// Call inside a click/tap handler so downloads have sticky user activation.
async function streamTranslation(input, sourceLanguage, targetLanguage, targetEl) {
const translator = await Translator.create({ sourceLanguage, targetLanguage });
try {
targetEl.textContent = "";
const stream = translator.translateStreaming(input);
for await (const chunk of stream) {
targetEl.textContent += chunk;
}
} finally {
translator.destroy();
}
}
Source: Translator API spec; Chrome for Developers Translator API guide.
Browser compatibility
| Browser | Support | Evidence / notes |
|---|---|---|
| Chrome (Android) | 161 | Enabled by default on Android (including Chrome Custom Tabs) in the milestone=161 listing and ChromeStatus 5106126157905920. BCD still lists chrome_android: false (freshness gap). |
| Chrome (Desktop) | 138 | Shipped in M138 per BCD api/Translator.json (BCD notes availability may be subject to geographical restrictions). |
| Android WebView | No | webview is null in ChromeStatus 5106126157905920 and false in BCD. |
| Edge | 148 (desktop) | Desktop Edge 148 per BCD and Microsoft Edge docs; Edge on Android status unknown. |
| Firefox | No | Unsupported in BCD; Mozilla’s standards position is Negative (mozilla/standards-positions#1015). |
| Safari | No | Unsupported in BCD; WebKit standards position has No signal (WebKit/standards-positions#339). |
api/Translator.json; ChromeStatus API record; webstatus.dev translator.
Security and privacy
- Per-origin process isolation: On Android, translation inference runs inside a per-origin
isolated_apputility process using the bundled on-device translation library, read-only language pack file descriptors, and browser-enforced 256 KiB input budgets so model execution is sandboxed away from the browser and other origins. - Verified model downloads: Language packs are downloaded on demand via Chromium’s Component Updater using CRX3- and SHA-256-verified packages, and require user activation before initiating downloads.
- No pack-presence fingerprinting via guardrails: Device storage and metered-network checks report
"unavailable"without revealing whether specific language packs are already installed on the device. - Local processing & enterprise governance: Page text never leaves the device during translation. Managed Android devices can disable the API and prevent model downloads entirely via the
TranslatorAPIAllowedenterprise policy.
TranslatorAPIAllowed; Translator API spec.
Specifications
see also
- gendn Chrome 157 — Language Detector API on Android
- MDN —
Translator(desktop API reference) · MDN — Translator and Language Detector APIs overview - Chrome for Developers — Translation with built-in AI · Official playground demo
- Chrome Enterprise —
TranslatorAPIAllowedpolicy - Explainer —
webmachinelearning/translation-api· Developer feedback issue #36 - ChromeStatus — Translator API on Android (5106126157905920)