To binary
To text
Source code
function convertToBinary() { const text = "YOUR PLAIN TEXT"; let binaryResult = ''; for (let i = 0; i < text.length; i++) { let binaryChar = text[i].charCodeAt(0).toString(2); binaryResult += binaryChar.padStart(8, '0') + ' '; } let binaryTextResult = binaryResult.trim(); // binaryTextResult } function convertToText() { const binaryText = "YOUR BINARY CODE"; let textResult = ''; const binaryArray = binaryText.split(' '); for (let i = 0; i < binaryArray.length; i++) { let charCode = parseInt(binaryArray[i], 2); textResult += String.fromCharCode(charCode); } // textResult }