// for UNICODE less/equal 0xFFFF var star = 0x2605; // ★ var s = String.fromCharCode(star) // ★ -> ★ var htmlEnt = `&#x${s.charCodeAt(0).toString(16)};` console.log(s," ->" ,htmlEnt)