The hamon on a katana is a visual effect on the blade that's created during the hardening process, but it's not just for aesthetics—it serves a functional purpose as well.
The creation of a hamon is a part of the differential hardening (or tempering) process. This process involves coating the blade in a clay slurry, with a thinner layer applied along the edge where the blade needs to be hardest, and a thicker layer along the spine for added toughness and flexibility. The blade is then heated and quenched (cooled rapidly) in water or oil.
The rapid cooling causes the steel in the thinner clay-covered area (the edge of the blade) to harden more than the steel in the thicker clay-covered area (the spine). This difference in hardness between the edge and the spine results in the distinctive wavy line or pattern known as the hamon.
The harder edge allows the katana to maintain sharpness, while the softer spine allows the blade to absorb shocks without breaking, making it more resilient during combat. The hamon thus serves as a visual indication of this differential hardening process.
However, it's important to note that not all hamons on commercially available katanas are genuine. Some are artificially applied for aesthetic purposes on blades that have not undergone the traditional differential hardening process. A genuine hamon is often a sign of a high-quality, traditionally made katana.