The invention discloses a device used in an electrified railway for controlling and compensating electric energy quality, and belongs to the field of power supply of electrified railways. The device comprises a passive filter formed by a second-order high-pass filter, a group of voltage source type converters, and a phase reactor, wherein the passive filter is used for providing an electric locomotive on an electrified railway with reactive power and filtering harmonic current generated by the electric locomotive; the voltage source type converters can generate voltage with controllable amplitude, phase and frequency and are used for negative sequence compensation, flicker control and the like of a traction power supply system of an electric railway; and the voltage source type converters are connected in parallel onto a 25kV traction electric network through the phase reactor and the passive filter. The device provided by the invention can solve the electric quality problems such as three phases imbalance, harmonic wave, voltage fluctuation, flicker and the like while compensating power factors of the power supply system of the electric railway. Additionally, with the fully play of the advantages of the passive filter, such as convenience for configuration and low cost, and the advantages of the voltage source type converter, such as small occupation area and low consumption as much as possible, the whole set of device can achieve the best technical specification and the greatest economic performance.