// Convert a number to a hexadecimal string with: hexString = yourNumber.toString(16); // and reverse the process with: yourNumber = parseInt(hexString, 16); // Example // (255).toString(16) == 'ff' && parseInt('ff', 16) == 255