Abstract In this paper, an analytical formula for the sensitivity of optical sensors based on one-dimensional photonic crystals (PCs) with a defect was derived for the first time. Based on this formula, a comparative analysis of the sensitivity of defected PCs with and without mirror symmetry was carried out. In addition, the exact values of sensitivity in the limit of an infinite PC with a quarter-wave unit cell were obtained. It was shown that the sensitivity of a defective PC with an infinitely thick defect layer is equal to that of a perfectly reflecting Fabry-Perot resonator and does not depend on the specific structure of the PC. The results of this work provide a significant simplification of the analysis and optimization of optical sensors based on defective PCs, as well as a better understanding of the numerous numerical results obtained previously.