Tankless water heaters work by heating water directly as it flows through the unit. When a hot water tap is turned on, cold water enters the unit and passes through a heat exchanger, where it is rapidly heated using either gas burners or electric heating elements. The heated water then exits the unit and flows to the desired fixture.