We describe the preparation of two-dimensionally patterned polyaniline (PANI) thin films via microtransfer molding and electropolymerization techniques. This procedure yields reproducible conducting polymer patterns with excellent feature periodicity, making them useful as diffraction gratings. The fabricated polymer gratings were characterized via tapping-mode atomic force microscopy. Spectroelectrochemistry was used to characterize the optical properties associated with various intrinsic PANI redox states. In accordance with the Kramers–Kronig relation for change-in-absorptivity and change-in-index-of-refraction, electrochemically induced changes in refractive index (detected via changes in diffraction efficiency) were observed to coincide with electrochemically-induced changes in the PANI electronic absorption spectrum. In addition, the higher oxidation states of PANI and the associated changes in refractive index proved accessible via chemical oxidation. Beyond the novelty of a chemically-switchable transmission grating, the response of this system points to the possibility of developing diffraction-based chemical sensing schemes.