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() constructor returns a new TextDecoder object.
A string identifying the character encoding that this decoder will use. This may be any valid label.
Defaults to "utf-8".
options OptionalAn object with the following properties:
fatal OptionalA boolean value indicating if the TextDecoder.decode() method must throw a TypeError when decoding invalid data. It defaults to false, which means that the decoder will substitute malformed data with a replacement character.
ignoreBOM OptionalA boolean value indicating whether the byte order mark will be included in the output or skipped over. It defaults to false, which means that the byte order mark will be skipped over when decoding and will not be included in the decoded text.
Thrown if the value of label is unknown, or is one of the values leading to a 'replacement' decoding algorithm ("iso-2022-cn" or "iso-2022-cn-ext").
| Encoding # ref-for-dom-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.