Back

Bytes to KB MB GB TB

Javascript byte conveting function demo

Byte convert
Byte :
<div id="preview-size"></div>
<input type="number" id="byte" value="1024">
<button id="convert-byte">Convert</button>

<script>
document.getElementById("convert-byte").onclick = function(){
  let byte = document.getElementById("byte").value;
  let result = byte_format(byte);
  document.getElementById("preview-size").innerHTML= result
}
</script>
Convert text size
Add your tex here click convert size:
<div id="preview-size"></div>
<textarea id="text-val">Lorem ipsum dolor sit amet,....</textarea>
<button id="convert">Convert</button>

<script>
document.getElementById("convert").onclick = function(){
  let text = document.getElementById("text-val").value;
  var size = new Blob([text]).size;
  let result = byte_format(size);
  document.getElementById("preview-size").innerHTML= result
}
</script>