Online tool for converting string to ASCII characters and ASCII characters to string. Conversion is done in the browser, no data is sent to the backend.

HTML
CSS
JavaScript
<div id="converter">
  <div id="textareas">
    <textarea id="input" placeholder="Input"></textarea>
    <textarea id="output" placeholder="Output"></textarea>
  </div>
  <div id="converter-buttons">
    <span>
      <button id="convert">Convert</button>
      <select id="conversion-type">
        <option value="string">String to ASCII</option>
        <option value="dec">ASCII to String</option>
      </select>
    </span>
    <button id="swap-values">Swap values</button>
  </div>
</div>
#converter {
  margin-top: 30px;
}
#textareas {
  display: flex;
  flex-direction: row;
}
#converter textarea {
  width: 50%;
  padding: 5px;
  min-height: 200px;
  font-size: 14px;
  color: #404040;
}
.applet-body {
  border: none !important;
}
#converter-buttons {
  display: flex;
  justify-content: space-between;
  margin-top: 5px;
}
#convert, #conversion-type, #swap-values {
  font-size: 15px;
  border-radius: 5px;
}
document.querySelector('#convert').onclick = function() {
  const inputMode = document.querySelector('#conversion-type').value;
  const input = document.querySelector('#input').value;
  if (!input) return;

  let output = '';

  if (inputMode === 'string') {
    input.split('').forEach(char => {
      output += char.charCodeAt(0) + ' ';
    });
  } else {
    input.split(' ').forEach(code => {
      output += String.fromCharCode(code);
    });
  }

  document.querySelector('#output').value = output;
}

document.querySelector('#swap-values').onclick = function() {
  const input = document.querySelector('#input').value;
  const output = document.querySelector('#output').value;
  document.querySelector('#input').value = output;
  document.querySelector('#output').value = input;
}
Tweet this | Share on LinkedIn |