Pages

Wednesday, 4 December 2024

ASCII to Binary Converter Tool



ASCII to Binary Converter

ASCII to Binary Converter

Convert ASCII text to Binary format

Binary Output

* { margin: 0; padding: 0; box-sizing: border-box; } body { font-family: 'Arial', sans-serif; background-color: #f0f4f8; color: #333; display: flex; justify-content: center; align-items: center; height: 100vh; margin: 0; } .container { background-color: #fff; border-radius: 10px; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); width: 90%; max-width: 600px; padding: 20px; } .header { text-align: center; margin-bottom: 20px; } .header h1 { color: #4CAF50; font-size: 2rem; } .header p { font-size: 1rem; color: #777; } .input-section { margin-bottom: 20px; } textarea { width: 100%; height: 100px; padding: 10px; font-size: 1rem; border: 2px solid #ddd; border-radius: 5px; resize: vertical; margin-bottom: 10px; outline: none; } textarea:focus { border-color: #4CAF50; } button { width: 100%; padding: 12px; font-size: 1.2rem; background-color: #4CAF50; color: white; border: none; border-radius: 5px; cursor: pointer; transition: background-color 0.3s ease; } button:hover { background-color: #45a049; } .output-section { margin-top: 20px; } #binaryOutput { height: 150px; font-family: monospace; background-color: #f4f4f4; border: 2px solid #ddd; } @media (max-width: 600px) { .container { width: 100%; padding: 15px; } textarea { height: 80px; } button { font-size: 1rem; } } // Function to convert ASCII to binary function convertToBinary() { let asciiInput = document.getElementById("asciiInput").value; if (asciiInput === "") { alert("Please enter some ASCII text."); return; } let binaryOutput = ""; for (let i = 0; i < asciiInput.length; i++) { // Convert each character to binary and append to the output binaryOutput += asciiInput.charCodeAt(i).toString(2).padStart(8, '0') + " "; } document.getElementById("binaryOutput").value = binaryOutput.trim(); }