Soap nuts are a berry shell that naturally contains a cleaning agent that works like detergent
The natural cleaning agent found in these berries is called saponin. Saponin works as a surfactant, breaking the surface tension of the water to penetrate the fibers of your clothing, lifting stains from the fabric, and leaving dirt suspended in the water that is rinsed away. Regular sort bought detergents contain chemical surfactants too, this is just a natural source.