<input><pre></pre>
<script>
var input = document.querySelector('input'),
pre = document.querySelector('pre');
input.addEventListener('input', e=>{
pre.textContent = JSON.stringify(
input.value.split('').reduce(
(obj, char) => (char in obj ? obj[char]++ : obj[char] = 1, obj),
Object.create(null)
),
0,
' '
).slice(2,-2)
})
</script>