Web TextEncoder API | TextEncoder encode() method Last Updated : 20 Aug, 2019 Comments Improve Suggest changes Like Article Like Report In HTML there is a TextEncoder Interface which has a method encode() which returns an integer array containing the input parameter in encoded form. Syntax: var str = encoder.encode( str ); Return: It return an Uint8array that contains the text which is given in parameters encoded with the specific method for that TextEncoder object. Example: This example uses TextEncoder encode() method. html <!DOCTYPE html> <html> <head> <title> Web TextEncoder API | TextEncoder encode() method </title> </head> <body style="text-align:center;"> <h1 style="color:green;"> GeeksforGeeks </h1> <h3>Web TextEncoder API | TextEncoder encode() method</h3> <button onclick="getTextEncoder ();"> Get encoded form </button> <p>Text = "Welcome to GeeksforGeeks"</p> <p id='TextEncoder'></p> <script type="text/javascript"> function getTextEncoder() { var string = "geeksforgeeks is best"; var textEncoder = new TextEncoder(); let encoded = textEncoder.encode(string); document.getElementById("TextEncoder").innerHTML = "Encoded form:" + encoded; } </script> </body> </html> Output: Before clicking the button: After clicking the button: Supported Browsers: The browsers supported by TextEncoder encode() method are listed below: Google Chrome 38 Firefox 19 Opera 25 Safari 10.1 Comment More infoAdvertise with us Next Article Web TextEncoder API | TextEncoder encode() method D DeepakDev Follow Improve Article Tags : JavaScript Web Technologies HTML Web-API Similar Reads Web API | TextDecoder decode() Method The decode() method in TextDecoder API is used to takes a stream of bytes as input and emits a stream of code points. The TextEncoder decode() method takes an ArrayBuffer containing the encoded data and options object and returns the original string (i.e. decoded string). Syntax: decoder.decode(buff 2 min read Web API TextEncoder encodeInto() Method The encodeInto() method in TextEncoder API is used to take stream of points and emits the stream of UTF-8 bytes. All instances of TextEncoder only support UTF-8 encoding. The TextEncoder.encodeInto() takes a string to encode and an array to hold the encoded result and returns an object back. Syntax: 2 min read TextDecoder Web API | TextDecoder constructor In HTML there is a TextDecoder Interface of which we can create a TextDecoder object for the encoding specified in parameter. Syntax: decoder = new TextDecoder( utf-Label, option ); Parameters: This constructor accepts two parameters which are mentioned above and described below: utf-Label: Label of 2 min read Node.js stringDecoder.end() Method The stringDecoder.end() method is used to return all the remaining input stored in the internal buffer as a string. This method ensures that any incomplete UTF-8 and UTF-16 characters are replaced with substitution characters that are appropriate for character encoding. When the optional buffer argu 2 min read Node.js stringDecoder.write() Method The stringDecoder.write() method is used to return a decoded string from the given Buffer, TypedArray or DataView. This method also ensures that any incomplete multibyte characters at the end of the buffer are omitted from the returned string. These characters are stored in an internal buffer for th 2 min read Like