Many quantum emitters have been measured close or near the grain boundaries of the two-dimensional hexagonal boron nitride where various Stone–Wales defects appear. We show by means of first principles density functional theory calculations that the pentagon–heptagon Stone–Wales defect is an ultraviolet emitter and its optical properties closely follow the characteristics of a 4.08-eV quantum emitter, often observed in polycrystalline hexagonal boron nitride. We also show that the square–octagon Stone–Wales line defects are optically active in the ultraviolet region with varying gaps depending on their density in hexagonal boron nitride. Our results may introduce a paradigm shift in the identification of fluorescent centres in this material.