Deno class TextDecoder and TextEncoder

What is Deno?

Deno is a small, general-purpose runtime environment for JavaScript with first-class support for various interfaces, ECMAScript modules, and seamless TypeScript integration.

Class TextDecoder

Deno class contains a widely used method, decode(). This function runs the decoder based on the encoding used, and the method returns the result from the encoding’s decoder.

Constructors

constructor(label?: string, options?: { fatal: boolean, ignoreBOM: boolean })
// parameters of constructor function

Properties

readonly encoding: string
// Returns the name of the encoding in lowercased form.
readonly fatal: boolean
// Returns true if error mode is "fatal".
readonly ignoreBOM
// Returns true if ignore BOM flag is set.
readonly [Symbol.toStringTag]: string

Methods

decode(input?: BufferSource, options?: { stream: false }): string
// Returns the result from the  running of encoding's decoder.

Class TextEncoder

Deno class which contains a method encode() which returns the result of running UTF-8’s encoder.

Properties

readonly encoding
// Returns type of encoding which is "utf-8".
readonly [Symbol.toStringTag]: string

Methods

encode(input?: string): Uint8Array
// Returns the result of running UTF-8's encoder.
encodeInto(input: string, dest: Uint8Array): {read: number, written: number}

Free Resources

Copyright ©2026 Educative, Inc. All rights reserved