Polyaniline (PANI) was synthesized by the oxidative polymerization of aniline with potassium dichromate as an oxidant. PANI was characterized by IR, UV, and TG. The effect of inclusion of CoCl 2 , NiCl 2 , and FeCl 3 on the thermal and optical properties of polyaniline has been studied. The results showed that the doped PANIs are thermally more stable than the pure PANI. The optical band gap of the doped PANIs is smaller than the pure polymer. PANI has higher corrosion inhibition of Al than the doped polymers. Doped PANIs have been used as molecular precursors for the production of Co 3 O 4 , NiO, and Fe 2 O 3 nanoparticles by thermal decomposition route. The structures of the obtained metal oxides have been characterized by XRD and TEM. The average sizes of the prepared nanoparticles were estimated as 22, 17, and 13 nm for Co 3 O 4 , NiO, and Fe 2 O 3 samples, respectively.