Visible spectral absorption studies of an indicator trapped in the microenvironment of polypyrrole (PPY) and polyaniline (PANI) films were used to investigate the change in pH accompanying changes in oxidation state of the polymer. An indicator, bromophenol blue was incorporated in the conducting polymer film during the electropolymerization process. In situ UV–vis spectra of these films were recorded in aqueous solution of KCl. The results obtained show that with increasing potential of the film, the pH of the microenvironment decreases both for PPY and PANI. The change in pH is greater in the potential range where the change in electronic conductivity is also greater.