This paper discusses the development of an improved diode clamped twelve-level inverter using an optimized selective harmonic elimination (SHE) technique based on the dog leg optimization algorithm. The study demonstrates how this method effectively eliminates specific low-order harmonics while retaining the fundamental component, achieving negligible total harmonic distortion (THD) through Matlab/Simulink simulations. The findings highlight the advantages of the diode clamped multilevel inverter (DCMLI) in high power applications, showcasing various modulation techniques and the proposed method's effectiveness in enhancing power quality.