The invention relates to a device for pasteurizing or sterilizing a mass of foodstuff, which device comprises: a feed for supplying the mass; heating means for heating the mass, comprising: a tube of an electrically and magnetically inert material connecting to the feed; a system of mutually co-acting electrodes which are added to the tube and which are connected to an RF power generator which generates energy at a frequency in the range of about 10-50 MHZ to the electrodes such that the mass present in the first tube can be heated during its first residence time in this first tube; and a discharge for discharging the mass, wherein the electrodes have rounded corners on their end zones facing toward the inner surface of the tube for the purpose of locally limiting the strength of the electric field generated by the electrodes.