In this study, a harmonic oscillator with position-dependent mass is investigated. Firstly, as an introduction, we give a full description of the system by constructing its classical Lagrangian;thereupon, we derive the related classical equations of motion such as the classical Euler–Lagrange equations. Secondly, we fractionalize the classical Lagrangian of the system, and then we obtain the corresponding fractional Euler–Lagrange equations(FELEs). As a final step, we give the numerical simulations corresponding to the FELEs within different fractional operators.Numerical results based on the Caputo and the Atangana-Baleanu-Caputo(ABC) fractional derivatives are given to verify the theoretical analysis.