Context. Photochemistry is a key process that drives planetary atmospheres away from local thermodynamic equilibrium. Recent observations of the H2 dominated atmospheres of hot gas giants have detected SO2 as one of the major products of this process. Aims. We investigated which chemical pathways lead to the formation of SO2 in an atmosphere, and we investigated which part of the flux from the host star is necessary to initiate SO2 production. Methods. We used the publicly available S–N–C–H–O photochemical network in the VULCAN chemical kinetics code to compute the disequilibrium chemistry of an exoplanetary atmosphere. Results. We find that there are two distinct chemical pathways that lead to the formation of SO2. The formation of SO2 at higher pressures is initiated by stellar flux >200 nm, whereas the formation of SO2 at lower pressures is initiated by stellar flux <200 nm. In deeper layers of the atmosphere, OH is provided by the hydrogen abstraction of H2O, and sulfur is provided by the photodissociation of SH and S2, which leads to a positive feedback cycle that liberates sulfur from the stable H2S molecule. In the upper layers of the atmosphere, OH is provided by the photodissociation of H2O, and sulfur can be liberated from H2S either by the photodissociation of SH and S2, or by the hydrogen abstraction of SH. Conclusions. We conclude that the stellar flux in the 200–350 nm wavelength range as well as the ratio of near-UV to UV radiation are important parameters determining the observability of SO2. In addition, we find that there is a diversity of chemical pathways to the formation of SO2. This is crucial for the interpretation of SO2 detections and derived elemental abundance ratios, and for overall metallicities.

