Text Compression Demo
Letter Frequencies (editable):
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Enter a message and click Compress to see the Huffman coding and compression ratio.
How Huffman Coding Works
1. Count frequency of each character in the text
2. Build a binary tree with frequent characters having shorter paths
3. Assign binary codes based on tree paths (left=0, right=1)
4. Replace each character with its binary code for compression
Result: Frequent characters get shorter codes, achieving better compression!