A device for thermally processing rails comprising: - a gas pipework coupled with chambers, - a water pipework, - cooling modules, each of which comprises an upper chamber and a lateral chamber for feeding the coolant medium onto a top of the rail, wherein baffles are installed at least in the upper chambers, characterized in that - said device comprises a unit for pulsewisely quasicontinuously and/or continuously injecting water into a gas flow, the unit comprising pulse injectors governed by an injection control unit for injecting, in a pulsewise quasicontinuous and/or continuous mode, water into a flow of gas medium with adjustably changeable humidity and pressure of the gas in order to change the cooling ability of the medium, - said cooling modules comprise an upper chamber for collecting the formed coolant medium and a lateral chamber for collecting the formed coolant medium and each of cooling modules comprises also a lower chamber for collecting the formed coolant medium for feeding coolant medium simultaneously onto both top and underside of the rail, - the pipes of said gas pipework are coupled with said chambers (3, 4, 5) through transition flanges with the built-in pulse injectors with discharge openings directed into said pipes of the gas pipework in order to form the coolant medium, - said transition flanges formed as a frustum of a pyramid to couple said gas pipework with the chamber (3, 4, 5) are configured to change gradually the velocity of the flow of the formed coolant medium at the entrance into said chambers (3, 4, 5), - said baffles are configured to provide dividing the flow of the formed coolant medium within the chambers (3, 4, 5). - a gas pipework coupled with chambers, - a water pipework, - cooling modules, each of which comprises an upper chamber and a lateral chamber for feeding the coolant medium onto a top of the rail, wherein baffles are installed at least in the upper chambers, characterized in that - said device comprises a unit for pulsewisely quasicontinuously and/or continuously injecting water into a gas flow, the unit comprising pulse injectors governed by an injection control unit for injecting, in a pulsewise quasicontinuous and/or continuous mode, water into a flow of gas medium with adjustably changeable humidity and pressure of the gas in order to change the cooling ability of the medium, - said cooling modules comprise an upper chamber for collecting the formed coolant medium and a lateral chamber for collecting the formed coolant medium and each of cooling modules comprises also a lower chamber for collecting the formed coolant medium for feeding coolant medium simultaneously onto both top and underside of the rail, - the pipes of said gas pipework are coupled with said chambers (3, 4, 5) through transition flanges with the built-in pulse injectors with discharge openings directed into said pipes of the gas pipework in order to form the coolant medium, - said transition flanges formed as a frustum of a pyramid to couple said gas pipework with the chamber (3, 4, 5) are configured to change gradually the velocity of the flow of the formed coolant medium at the entrance into said chambers (3, 4, 5), - said baffles are configured to provide dividing the flow of the formed coolant medium within the chambers (3, 4, 5).