We present the first investigation of photoisomerization of the azo-based electroactive polyimide (PI)/amino-functionalized multiwalled carbon nanotube (MWCNT) composite electrode on the effect of electrochemical sensing for ascorbic acid (AA). First, MWCNTs were grafted with 4-aminobenzoic acid in a medium of polyphosphoric acid/phosphorous pentoxide to obtain MWCNTs functionalized with 4-aminobenzoyl groups (AF-MWCNTs). Subsequently, photoactive and electroactive PI/AF-MWCNT composites (PEPACCs) were prepared by introducing pendant conjugated oligoaniline (amino-capped aniline trimer) in the main chain and azobenzene chromophores in the side chain, in the presence of AF-MWCNTs. Photoactive and electroactive PI (PEPI) and PEPACCs were characterized by 1 H NMR spectra, UV−visible absorption spectra, cyclic voltammetry (CV) and transmission electron microscopy. The CV study shows that the PEPACCs have higher electroactivity than PEPI. The redox and reversible photoisomerization (i.e. cis ↔ trans) behavior of PEPACCs was analyzed by in situ monitoring through systematic studies of CV and UV−visible spectroscopy. The light of the UV lamp was 365 nm. It should be noted that the sensor constructed from a trans-PEPACC-modified carbon-paste electrode (CPE) demonstrated a higher electrocatalytic activity by 2.75-fold and 1.12-fold towards the oxidation of AA compared with those constructed using a PEPI-and cis-PEPACC-modified CPE, respectively. The detection limit of the trans-PEPACC-modified electrode was 1.73-fold and 1.70-fold lower than that of PEPI-and cis-PEPACC-modified CPE. Moreover, the differential pulse voltammetry data showed that the trans-PEPACC-modified electrode had high electrochemical sensing ability for the determination of AA, dopamine and uric acid.