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

The TextEncoder() constructor returns a newly created utf-8 TextEncoder object.


encoder = new TextEncoder(); 


  • TextEncoder() takes no parameters since Firefox 48 and Chrome 53

Note: Prior to Firefox 48 and Chrome 53, an encoding type label was accepted as a paramer to the TextEncoder object, since then both browers have removed support for any encoder type other than utf-8, to match the spec. Any type label passed into the TextEncoder constructor will now be ignored and a utf-8 TextEncoder will be created.


  • TextEncoder() throws no exceptions since Firefox 48 and Chrome 53

Note: Prior to Firefox 48 and Chrome 53 an exception would be thrown for an unknown encoding type.


Specification Status Comment
The definition of 'TextEncoder()' in that specification.
Living Standard Initial definition

Browser compatibility

FeatureChromeEdgeFirefoxInternet ExplorerOperaSafari
Basic support


38 — 532



38 — 484

19 — 385


No25 No
FeatureAndroid webviewChrome for AndroidEdge mobileFirefox for AndroidOpera AndroidiOS SafariSamsung Internet
Basic support3838 ?


38 — 484

19 — 385


? No ?

1. Does not accept parameters. Supports only utf-8 encoding.

2. Throws RangeError exception for unknown encoding types.

3. The constructor accepts an encoding type label argument, but the value is ignored. Only utf-8 encoding is supported.

4. If the encoding type label argument is invalid, then a RangeError exception is thrown.

5. If the encoding type label argument is invalid, then a TypeError exception is thrown.

6. Firefox 18 implemented an earlier and slightly different version of the specification.

See also

Document Tags and Contributors

Last updated by: fscholz,