Modular multilevel converters (MMCs) are widely used for DC to AC power conversion; however, they produce switching harmonics resulting in poor power quality and system performance. Several offline methods including harmonic elimination pulse width modulation (HEPWM) have been proposed to suppress these harmonics; however, they do not guarantee smooth and rapid operation of power system under varying loads. In this work, novel online technique which combines merits of Differential Evolution (DE) and Newton Raphson (NR) methods to solve complex simultaneous transcendental trigonometric set of HEPWM equations is proposed. Simulation results have cemented the viability of the algorithm as it solves HEPWM equations in only (on average) 5 iterations (normally hundreds of iterations are required in offline solution). In addition, the THD value of filtered line to line output voltage is restricted to less than 0.5% of the fundamental component which is significantly better than 8% and 5% limits allowed by IEEE standard 519-2014. Hardware results are also presented which verify the applicability of proposed algorithm under online conditions.