Text encoding and decodingBaseline · Widely available
The TextEncoder API transforms a stream of code points into a byte stream with UTF-8 encoding, and TextDecoder does the reverse.
Supported in all major browsers for at least 30 months — safe to use without fallbacks. Baseline since Jan 15, 2020. Widely available since Jul 15, 2022.
Browser support
DesktopChrome
1–37Not supported
38+Supportedsince Oct 7, 2014
Current: 155Edge
12–18Not supported
79+Supportedsince Jan 15, 2020
Current: 154Firefox
1–18Not supported
19+Supportedsince Feb 19, 2013
Current: 157Safari
1–10Not supported
10.1+Supportedsince Mar 27, 2017
Current: 27MobileChrome Android
18–37Not supported
38+Supportedsince Oct 8, 2014
Current: 155Firefox Android
4–18Not supported
19+Supportedsince Feb 19, 2013
Current: 157Safari iOS
1–10Not supported
10.3+Supportedsince Mar 27, 2017
Current: 27How to use
This feature is Baseline widely available — use it freely, no fallback needed.
Example
Full syntax and examples are on MDN: TextDecoder.
Feature detection
JS · check before using
if ("TextDecoder" in globalThis && "encoding" in TextDecoder.prototype) {
// TextDecoder.encoding is available
}Documentation (MDN)
Specification
Usage share
Sub-features
Support for each part of the feature (25). The overall table above shows when the whole feature works.
| Sub-feature | Chrome | Edge | Firefox | Safari | Chrome Android | Firefox Android | Safari iOS |
|---|---|---|---|---|---|---|---|
| TextDecoder | 38 | 79 | 19 | 10.1 | 38 | 19 | 10.3 |
| TextDecoder.TextDecoder | 38 | 79 | 19 | 10.1 | 38 | 19 | 10.3 |
| TextDecoder.decode | 38 | 79 | 19 | 10.1 | 38 | 19 | 10.3 |
| TextDecoder.encoding | 38 | 79 | 19 | 10.1 | 38 | 19 | 10.3 |
| TextDecoder.fatal | 38 | 79 | 36 | 10.1 | 38 | 36 | 10.3 |
| TextDecoder.ignoreBOM | 38 | 79 | 63 | 10.1 | 38 | 63 | 10.3 |
| TextDecoder.worker_support | 38 | 79 | 20 | 10.1 | 38 | 20 | 10.3 |
| TextDecoderStream | 71 | 79 | 105 | 14.1 | 71 | 105 | 14.5 |
| TextDecoderStream.TextDecoderStream | 71 | 79 | 105 | 14.1 | 71 | 105 | 14.5 |
| TextDecoderStream.encoding | 71 | 79 | 105 | 14.1 | 71 | 105 | 14.5 |
| TextDecoderStream.fatal | 71 | 79 | 105 | 14.1 | 71 | 105 | 14.5 |
| TextDecoderStream.ignoreBOM | 71 | 79 | 105 | 14.1 | 71 | 105 | 14.5 |
| TextDecoderStream.readable | 71 | 79 | 105 | 14.1 | 71 | 105 | 14.5 |
| TextDecoderStream.writable | 71 | 79 | 105 | 14.1 | 71 | 105 | 14.5 |
| TextEncoder | 38 | 79 | 18 | 10.1 | 38 | 18 | 10.3 |
| TextEncoder.TextEncoder | 38 | 79 | 18 | 10.1 | 38 | 18 | 10.3 |
| TextEncoder.encode | 38 | 79 | 18 | 10.1 | 38 | 18 | 10.3 |
| TextEncoder.encodeInto | 74 | 79 | 66 | 14.1 | 74 | 66 | 14.5 |
| TextEncoder.encoding | 38 | 79 | 18 | 10.1 | 38 | 18 | 10.3 |
| TextEncoder.worker_support | 38 | 79 | 20 | 10.1 | 38 | 20 | 10.3 |
Show 5 more
| Sub-feature | Chrome | Edge | Firefox | Safari | Chrome Android | Firefox Android | Safari iOS |
|---|---|---|---|---|---|---|---|
| TextEncoderStream | 71 | 79 | 105 | 14.1 | 71 | 105 | 14.5 |
| TextEncoderStream.TextEncoderStream | 71 | 79 | 105 | 14.1 | 71 | 105 | 14.5 |
| TextEncoderStream.encoding | 71 | 79 | 105 | 14.1 | 71 | 105 | 14.5 |
| TextEncoderStream.readable | 71 | 79 | 105 | 14.1 | 71 | 105 | 14.5 |
| TextEncoderStream.writable | 71 | 79 | 105 | 14.1 | 71 | 105 | 14.5 |