This paper deals with the four-leg two-level inverter used as a Shunt Active Power Filter (SAPF) to compensate the harmonics current, unbalanced currents, reactive power and neutral current in four wires power system grid connection. The control of the SAPF is based on a three-dimensional space vector pulse width modulation SVPWM which was recently proposed. This algorithm is benefiting from the advantages of the two SVPWM algorithms used in alpha beta gamma and abc coordinates which were previously presented in other papers. The strategy adopted for identifying the reference currents of the SAPF is the pq theory based on a PLL circuit, due to its easy implementation in real time, where the drawbacks of unbalanced power source voltages and the generated hidden currents are taken into account. To prove the compensation capabilities of the SAPF in ensuring sinusoidal waveforms of the source line currents, a neglected neutral current and a neglected shift phase between the line source currents and its corresponding voltages, a real-time investigation was curried out. The results obtained demonstrate the effectiveness of the four-leg SAPF under the proposed control strategy to fulfill the compensation requirement in four wire power system network.