In the present work, oxalic acid doped molecularly imprinted conducting polyaniline film for melamine detection was prepared by in-situ-electrochemical polymerization on the glassy carbon electrode (GCE) using melamine as template. The optimal monomer/template molar ratio was attained to be 0.2:0.1:0.01 (aniline: oxalic acid: melamine) and molecular recognition properties towards melamine were evaluated by differential pulse voltammetry. Under optimal conditions the imprinted polymer film was used to detect different concentrations of melamine in standard solutions and real milk samples. Compared with the nonimprinted polymer (NIP), the molecularly imprinted polymer (MIP) film showed higher affinity and sensitivity towards melamine with a linear range, quantification limit and detection limit of 0.5-200 nM, 1.375 nM and 0.413 nM respectively. Furthermore, the polymer blend film showed good selectivity toward melamine, stability, reproducibility and practical applications for the determination of melamine in infant formula milk with the recovery of 92.32-102.49%. The doping of the polymer with oxalic acid enhanced the conductivity and sensitivity of the sensor.