Skip to main content
3 of 3
added 2 characters in body
Neil
  • 177.3k
  • 12
  • 74
  • 281

JavaScript (ES6), 78 74 bytes

f=(n,i)=>n<999.5?i?n.toPrecision(n<1^3)+' KMG'[i]+'iB':n+'B':f(n/1024,-~i)
<input oninput=o.textContent=f(this.value)><pre id=o>

Edit: Saved 4 bytes thanks to @Arnauld.

Neil
  • 177.3k
  • 12
  • 74
  • 281