A new pillared Ti3C2Tx MXene compound, which exhibits tunable interlayer spacing property through the introduction of photoisomeric cationic azobenzene derivatives, is prepared. It displays highly reversible photo-switching for conductivity, capacitance and chemi-resistive gas sensing properties, which will contribute to the design of novel 2D MXene-based optic-electric sensing and switching devices.