Skip to content
Related Articles
Open in App
Not now

Related Articles

Node.js String Decoder Complete Reference

Improve Article
Save Article
Like Article
  • Last Updated : 23 Feb, 2023
Improve Article
Save Article
Like Article

The string Decoder module provides an API for decoding Buffer objects into strings.



// Node.js program to demonstrate the
// stringDecoder.write() Method
// Import the string_decoder module
// and get the StringDecoder class
// using object destructuring
const { StringDecoder } = require("string_decoder");
// Create a new instance of the decoder
const decoder = new StringDecoder("utf-8");
const text_one = Buffer.from("GeeksforGeeks", "utf-8");
let decoded_text = decoder.write(text_one);
console.log("Decoded Text:", decoded_text);


Decoded Text: GeeksforGeeks

The Complete List of String Decoder are listed below:

Class: StringDecoder

Class: StringDecoder Methods


stringDecoder.end() Return all the remaining input stored in the internal buffer as a string.
stringDecoder.write() Return a decoded string from the given Buffer, TypedArray, or DataView. 
My Personal Notes arrow_drop_up
Like Article
Save Article
Related Articles

Start Your Coding Journey Now!