Huffman coding is a statistical compression technique that assigns variable-length codes to characters based on their frequency of occurrence. It builds a Huffman tree by prioritizing characters from most to least frequent, then assigns codes by traversing the tree left for 0 and right for 1. This results in shorter codes for more common characters, compressing text files into fewer bits than standard ASCII encoding. The receiver reconstructs the same Huffman tree to decode the bitstream back into the original text.