New R-matrix calculations of electron impact excitation rates for transitions among the 2s22p, 2s2p2 and 2p3 levels of S XII are presented. These data are subsequently used to derive the theoretical electron density diagnostic emission line intensity ratios R1=I(215.16 Å)/I(299.50 Å), R2=I(218.19 Å)/I(299.50 Å), R3=I(288.40 Å)/I(299.50 Å), and R4=I(221.41 Å)/I(299.50 Å). A comparison of these with observational data for solar active regions and flares, obtained with the Naval Research Laboratory's S082A spectrograph on board Skylab and the Solar EUV Rocket Telescope and Spectrograph (SERTS), reveals that the electron densities determined from R1, R3, and R4 are consistent with each other. In addition, the densities deduced from these ratios are in good agreement with those estimated from diagnostic lines in Fe XIV or Fe XV, which are formed at similar electron temperatures to S XII. However, the R2 ratios in the flare observations imply densities smaller than those from Fe XIV/Fe XV, although the active region measurements do not show such discrepancies, suggesting that the 218.19 Å line may be blended with a transition from a high-temperature ion. An emission feature in the SERTS active region spectrum at 215.29 Å, previously identified as the 2s2p3P2-2s3s3S1 transition in O V, may be due primarily to the S XII 215.16 Å line.