Encoding API

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

The Encoding API provides a mechanism for handling text in various character encodings, including legacy non-UTF-8 encodings.

The API provides four interfaces: TextDecoder, TextEncoder, TextDecoderStream and TextEncoderStream.

Interfaces

Tutorials & tools

  • A shim allowing to use this interface in browsers that don't support it.
  • StringView – a C-like representation of strings based on typed arrays.

Specifications

Specification Status Comment
Encoding Living Standard Initial definition.

Browser compatibility

TextDecoder

DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
TextDecoderChrome Full support 38Edge Full support ≤79Firefox Full support 19
Full support 19
Partial support 18
Notes
Notes Implemented a slightly different version of the spec.
IE No support NoOpera Full support 25Safari Full support 10.1WebView Android Full support 38Chrome Android Full support 38Firefox Android Full support 19
Full support 19
Partial support 18
Notes
Notes Implemented a slightly different version of the spec.
Opera Android Full support YesSafari iOS Full support 10.3Samsung Internet Android Full support 3.0
TextDecoder() constructorChrome Full support 38Edge Full support ≤79Firefox Full support 19
Full support 19
Partial support 18
Notes
Notes Implemented a slightly different version of the spec.
IE No support NoOpera Full support 25Safari Full support 10.1WebView Android Full support 38Chrome Android Full support 38Firefox Android Full support 19
Full support 19
Partial support 18
Notes
Notes Implemented a slightly different version of the spec.
Opera Android ? Safari iOS Full support 10.3Samsung Internet Android Full support 3.0
decodeChrome Full support 38Edge Full support ≤79Firefox Full support 19
Full support 19
Partial support 18
Notes
Notes Implemented a slightly different version of the spec.
IE No support NoOpera Full support 25Safari Full support 10.1WebView Android Full support 38Chrome Android Full support 38Firefox Android Full support 19
Full support 19
Partial support 18
Notes
Notes Implemented a slightly different version of the spec.
Opera Android Full support YesSafari iOS Full support 10.3Samsung Internet Android Full support 3.0
encodingChrome Full support 38Edge Full support ≤79Firefox Full support 19
Full support 19
Partial support 18
Notes
Notes Implemented a slightly different version of the spec.
IE No support NoOpera Full support 25Safari Full support 10.1WebView Android Full support 38Chrome Android Full support 38Firefox Android Full support 19
Full support 19
Partial support 18
Notes
Notes Implemented a slightly different version of the spec.
Opera Android Full support YesSafari iOS Full support 10.3Samsung Internet Android Full support 3.0
fatalChrome Full support YesEdge Full support ≤79Firefox Full support YesIE No support NoOpera Full support YesSafari Full support 10.1WebView Android Full support YesChrome Android Full support YesFirefox Android Full support YesOpera Android Full support YesSafari iOS Full support 10.3Samsung Internet Android Full support Yes
ignoreBOMChrome Full support YesEdge Full support ≤79Firefox Full support YesIE No support NoOpera Full support YesSafari Full support 10.1WebView Android Full support YesChrome Android Full support YesFirefox Android Full support YesOpera Android Full support YesSafari iOS Full support 10.3Samsung Internet Android Full support Yes
Available in workersChrome Full support 38Edge Full support ≤79Firefox Full support 20IE No support NoOpera Full support 25Safari Full support 10.1WebView Android Full support 38Chrome Android Full support 38Firefox Android Full support 20Opera Android ? Safari iOS Full support 10.3Samsung Internet Android Full support 3.0

Legend

Full support
Full support
No support
No support
Compatibility unknown
Compatibility unknown
See implementation notes.
See implementation notes.

TextEncoder

DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
TextEncoder
Experimental
Chrome Full support 38Edge Full support 79Firefox Full support 19
Full support 19
Full support 18
Notes
Notes Firefox 18 implemented an earlier and slightly different version of the specification.
IE No support NoOpera Full support 25Safari Full support 10.1WebView Android Full support 38Chrome Android Full support 38Firefox Android Full support 19
Full support 19
Full support 18
Notes
Notes Firefox 18 implemented an earlier and slightly different version of the specification.
Opera Android Full support YesSafari iOS Full support 10.3Samsung Internet Android Full support 3.0
TextEncoder() constructor
Experimental
Chrome Full support 53
Notes
Full support 53
Notes
Notes Does not accept parameters. Supports only utf-8 encoding.
No support 38 — 53
Notes
Notes Throws RangeError exception for unknown encoding types.
Edge Full support 79
Notes
Full support 79
Notes
Notes Does not accept parameters. Supports only utf-8 encoding.
Firefox Full support 48
Notes
Full support 48
Notes
Notes The constructor accepts an encoding type label argument, but the value is ignored. Only utf-8 encoding is supported.
No support 38 — 48
Notes
Notes If the encoding type label argument is invalid, then a RangeError exception is thrown.
No support 19 — 38
Notes
Notes If the encoding type label argument is invalid, then a TypeError exception is thrown.
Full support 18
Notes
Notes Firefox 18 implemented an earlier and slightly different version of the specification.
IE No support NoOpera Full support 25Safari Full support 10.1WebView Android Full support 38Chrome Android Full support 38Firefox Android Full support 48
Notes
Full support 48
Notes
Notes The constructor accepts an encoding type label argument, but the value is ignored. Only utf-8 encoding is supported.
No support 38 — 48
Notes
Notes If the encoding type label argument is invalid, then a RangeError exception is thrown.
No support 19 — 38
Notes
Notes If the encoding type label argument is invalid, then a TypeError exception is thrown.
Full support 18
Notes
Notes Firefox 18 implemented an earlier and slightly different version of the specification.
Opera Android ? Safari iOS Full support 10.3Samsung Internet Android Full support 3.0
encode
Experimental
Chrome Full support 38Edge Full support 79Firefox Full support 19
Full support 19
Full support 18
Notes
Notes Firefox 18 implemented an earlier and slightly different version of the specification.
IE No support NoOpera Full support 25Safari Full support 10.1WebView Android Full support 38Chrome Android Full support 38Firefox Android Full support 19
Full support 19
Full support 18
Notes
Notes Firefox 18 implemented an earlier and slightly different version of the specification.
Opera Android Full support YesSafari iOS Full support 10.3Samsung Internet Android Full support 3.0
encodeInto
Experimental
Chrome Full support 74Edge Full support 79Firefox Full support 66IE No support NoOpera No support NoSafari No support NoWebView Android Full support 74Chrome Android Full support 74Firefox Android Full support 66Opera Android No support NoSafari iOS No support NoSamsung Internet Android Full support 11.0
encoding
Experimental
Chrome Full support 38Edge Full support 79Firefox Full support 19
Full support 19
Full support 18
Notes
Notes Firefox 18 implemented an earlier and slightly different version of the specification.
IE No support NoOpera Full support 25Safari Full support 10.1WebView Android Full support 38Chrome Android Full support 38Firefox Android Full support 19
Full support 19
Full support 18
Notes
Notes Firefox 18 implemented an earlier and slightly different version of the specification.
Opera Android Full support YesSafari iOS Full support 10.3Samsung Internet Android Full support 3.0
Available in workers
Experimental
Chrome Full support 38Edge Full support 79Firefox Full support 20IE No support NoOpera Full support 25Safari Full support 10.1WebView Android Full support 38Chrome Android Full support 38Firefox Android Full support 20Opera Android ? Safari iOS Full support 10.3Samsung Internet Android Full support 3.0

Legend

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