The development of solid materials that can be reversibly interconverted by light between forms with different physico-chemical properties is of great interest for separation, catalysis, optoelectronics, holography, mechanical actuation and solar energy conversion. Here, we describe a series of shape-persistent azobenzene tetramers that form porous molecular crystals in their E-configuration, the porosity of which can be tuned by changing the peripheral substituents on the molecule. Efficient E→Z photoisomerization of the azobenzene units takes place in the solid state and converts the crystals into a non-porous amorphous melt phase. Crystallinity and porosity are restored upon Z→E isomerization promoted by visible light irradiation or heating. We demonstrate that the photoisomerization enables reversible on/off switching of optical properties such as birefringence as well as the capture of CO2 from the gas phase. The linear design, structural versatility and synthetic accessibility make this new family of materials potentially interesting for technological applications.