To answer the original question: here is how you decode utf-8 in javascript:

http://ecmanaut.blogspot.ca/2006/07/encoding-decoding-utf8-in-javascript.html

Specifically,

function encode_utf8(s) {
  return unescape(encodeURIComponent(s));
}

function decode_utf8(s) {
  return decodeURIComponent(escape(s));
}

We have been using this in our production code for 6 years, and it has worked flawlessly.

Note, however, that escape() and unescape() are deprecated. See this.

Answer from CpnCrunch on Stack Overflow
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › API › TextDecoder
TextDecoder - Web APIs | MDN
June 28, 2025 - const utf8decoder = new TextDecoder(); // default 'utf-8' const encodedText = new Uint8Array([240, 160, 174, 183]); const output = document.querySelector("#output"); const decodeButton = document.querySelector("#decode"); decodeButton.addEventListener("click", () => { output.textContent = utf8decoder.decode(encodedText); }); const resetButton = document.querySelector("#reset"); resetButton.addEventListener("click", () => { window.location.reload(); });
🌐
GitHub
github.com › mathiasbynens › utf8.js
GitHub - mathiasbynens/utf8.js: A robust JavaScript implementation of a UTF-8 encoder/decoder, as defined by the Encoding Standard. · GitHub
utf8.decode('\xC2\xA9'); // → '\xA9' utf8.decode('\xF0\x90\x80\x81'); // → '\uD800\uDC01' // → U+10001 LINEAR B SYLLABLE B038 E · A string representing the semantic version number. utf8.js has been tested in at least Chrome 27-39, Firefox 3-34, Safari 4-8, Opera 10-28, IE 6-11, Node.js v0.10.0, Narwhal 0.3.2, RingoJS 0.8-0.11, PhantomJS 1.9.0, and Rhino 1.7RC4.
Author   mathiasbynens
🌐
DEV Community
dev.to › emnudge › decoding-utf-8-3947
Decoding UTF-8 - DEV Community
May 16, 2021 - While JavaScript uses UTF-16, HTML traditionally uses UTF-8. Only 8 bits? It looks like we barely got by with 16 bits! Are we going to reserve another few ranges?
🌐
MojoAuth
mojoauth.com › character-encoding-decoding › utf-8-encoding--javascript-in-browser
UTF-8 Encoding : JavaScript in Browser | Encoding Solutions Across Programming Languages
Node.js: Provides built-in modules like Buffer, which supports UTF-8 encoding and decoding for binary data. React: A popular JavaScript library for building user interfaces that natively supports UTF-8 encoded strings.
🌐
Tabnine
tabnine.com › home › code library
Code Library - Tabnine
July 25, 2024 - Get the answers and suggestions you need from our AI code assistant. Get started in minutes with a free 90 day trial of Tabnine Pro.
🌐
SSOJet
ssojet.com › character-encoding-decoding › utf-8-in-javascript-in-browser
UTF-8 in JavaScript in Browser | Encoding Standards for Programming Languages
If you opt for readAsArrayBuffer, you'll need to use TextDecoder('utf-8') to properly interpret the byte stream. Always confirm or set the charset for reliable UTF-8 handling. Decode Windows-1256 (Arabic) in JavaScript within your browser.
🌐
CodePen
codepen.io › piotezaza › pen › BvvMRm
Encode VS Decode UTF8 JavaScript
// ----- FUNCTIONS ----- // // ENCODE UTF8 function encode_utf8(s) { return unescape(encodeURIComponent(s)); } // DECODE UTF8 function decode_utf8(s) { return decodeURIComponent(escape(s)); } // ----- ENCODE & DECODE ----- // // ENCODE let from_1 = 'éàçè'; let result_1 = encode_utf8(from_1); $('.encode').html(result_1) // DECODE let from_2 = 'éà çè'; let result_2 = decode_utf8(from_2); $('.decode').html(result_2)
Find elsewhere
🌐
Blogger
ecmanaut.blogspot.com › 2006 › 07 › encoding-decoding-utf8-in-javascript.html
ecmanaut: Encoding / decoding UTF8 in javascript
From time to time it has somewhat ... I realized today: function encode_utf8(s) { return unescape(encodeURIComponent(s)); } function decode_utf8(s) { return decodeURIComponent(escape(s)); } 2012 Update: Monsur Hossain took a moment to explain how and why this works....
🌐
npm
npmjs.com › package › utf8
utf8 - npm
December 4, 2017 - (If you need to be able to encode ... see http://codepoints.net/U+00A9 ... Decodes any given UTF-8-encoded string (byteString) as UTF-8, and returns the UTF-8-decoded version of the string....
      » npm install utf8
    
Published   Dec 04, 2017
Version   3.0.0
🌐
Mother Eff
mothereff.in › utf-8
UTF-8 encoder/decoder
This tool uses utf8.js to UTF-8-encode any string you enter in the ‘decoded’ field, or to decode any UTF-8-encoded string you enter in the ‘encoded’ field.
🌐
JSFiddle
jsfiddle.net › onigetoc › QmT59
javascript utf8 encode-decode - JSFiddle - Code Playground
JSFiddle - Test your JavaScript, CSS, HTML or CoffeeScript online with JSFiddle.
🌐
GitHub
gist.github.com › chrisveness › bcb00eb717e6382c5608
Utf8 string encode/decode using regular expressions · GitHub
str="\\320\\223"+String.fromCodePoint(0x1F60E)+"..."; Utf8Decode(Utf8Encode(str).replace(/\\[0-9][0-9][0-9]/g,function(s){return String.fromCharCode(parseInt(s.substr(1),8));}))
🌐
Webtoolkit
webtoolkit.info › javascript_utf8.html
Javascript UTF-8 - Javascript tutorial with example source code
November 17, 2013 - The encoding known today as UTF-8 was invented by Ken Thompson. UTF-8 is a variable-length character encoding for Unicode. It can represent any character in the Unicode standard, yet is backwards compatible with ASCII. Use this Javascript to encode decode UTF-8 data.
🌐
GitHub
github.com › Benzinga › utf8js
GitHub - Benzinga/utf8js: Fast UTF-8 encoding/decoding for browsers and Node.
utf8.js is a fast UTF-8 encoder/decoder for JavaScript. It attempts to use native encoding/decoding methods whenever possible. It requires Promises and Typed Arrays, both of which can be polyfilled.
Author   Benzinga
🌐
Node.js
nodejs.org › api › string_decoder.html
String decoder | Node.js v26.5.0 Documentation
import { StringDecoder } from 'node:string_decoder'; import { Buffer } from 'node:buffer'; const decoder = new StringDecoder('utf8'); const cent = Buffer.from([0xC2, 0xA2]); console.log(decoder.write(cent)); // Prints: ¢ const euro = Buffer.from([0xE2, 0x82, 0xAC]); console.log(decoder.write(euro)); // Prints: € const { StringDecoder } = require('node:string_decoder'); const decoder = new StringDecoder('utf8'); const cent = Buffer.from([0xC2, 0xA2]); console.log(decoder.write(cent)); // Prints: ¢ const euro = Buffer.from([0xE2, 0x82, 0xAC]); console.log(decoder.write(euro)); // Prints: €
🌐
GitHub
gist.github.com › tudisco › 309475
javascript utf8 encode and decode · GitHub
The result should be F0 9D 8C 86. // …but with the current implementation: UTF8.encode('\uD834\uDF06') == '\xF0\x9D\x8C\x86' // false ... Decoder with full Unicode support: https://gist.github.com/pascaldekloe/62546103a1576803dade9269ccf76330