Grid-tied inverters play a vital role in distribution power systems to utilize renewable energy systems. Pulsewidth modulation (PWM) techniques are used for the inverters switching, where low- and high-frequency harmonics are produced at the terminal of the inverters. Therefore, a suitable filter between the inverter and grid is needed to prevent the power quality issue in the system. LCL filters with passive damping resistor are known as well-performed solution to minimize the produced harmonics in a grid-tied topology. In this article, a unified filter design approach for a grid-tied inverter is introduced. The proposed filter design approach is based on finding the precise maximum ripple current according to the modulation method and calculating the accurate optimal passive damping resistor. Unique formulas for the calculation of active power losses are introduced, which consider all the influential designing parameters. Ultimately, a new optimization-based algorithm is presented to determine the optimal size of the inductors and capacitor considering constraints on damping losses. The experimental results prove the efficiency of the proposed optimization-based method as well as the accuracy of introduced filter parameters expressions.