Get to know MDN better
This feature is well established and works across many devices and browser versions. It’s been available across browsers since January 2020.
Note: This feature is available in Web Workers.
The TextDecoder interface represents a decoder for a specific text encoding, such as UTF-8, ISO-8859-2, or GBK. A decoder takes an array of bytes as input and returns a JavaScript string.
Creates and returns a new TextDecoder.
The TextDecoder interface doesn't inherit any properties.
TextDecoder.encoding Read onlyA string containing the name of the character encoding system that this TextDecoder will use.
TextDecoder.fatal Read onlyA boolean indicating whether the error mode is fatal.
TextDecoder.ignoreBOM Read onlyA boolean indicating whether the byte order mark is ignored.
The TextDecoder interface doesn't inherit any methods.
TextDecoder.decode()Decodes the given bytes into a JavaScript string and returns it.
This example shows how to decode the UTF-8 encoding of the character "𠮷".
In this example, we decode the Russian text "Привет, мир!", which means "Hello, world." In our TextDecoder() constructor, we specify the Windows-1251 character encoding.
| Encoding # interface-textdecoder |
Enable JavaScript to view this browser compatibility table.
This page was last modified on Jun 28, 2025 by MDN contributors.
Your blueprint for a better internet.
Visit Mozilla Corporation’s not-for-profit parent, the Mozilla Foundation.
Portions of this content are ©1998–2026 by individual mozilla.org contributors. Content available under a Creative Commons license.