The [NII] 122 and 205 mu m transitions are powerful tracers of the ionized gas in the interstellar medium. By combining data from 21 galaxies selected from the Herschel KINGFISH and Beyond the Peak surveys, we have compiled 141 spatially resolved regions with a typical size of ~1 kiloparsec, with observations of both [NII] far-infrared lines. We measure [NII] 122/205 line ratios in the ~0.6-6 range, which corresponds to electron gas densities $n_e$~1-300 cm$^{-3}$, with a median value of $n_e$=30 cm$^{-3}$. Variations in the electron density within individual galaxies can be as a high as a factor of ~50, frequently with strong radial gradients. We find that $n_e$ increases as a function of infrared color, dust-weighted mean starlight intensity, and star formation rate surface density ($Sigma_{SFR}$). As the intensity of the [NII] transitions is related to the ionizing photon flux, we investigate their reliability as tracers of the star formation rate (SFR). We derive relations between the [NII] emission and SFR in the low-density limit and in the case of a log-normal distribution of densities. The scatter in the correlation between [NII] surface brightness and $Sigma_{SFR}$ can be understood as a property of the $n_e$ distribution. For regions with $n_e$ close to or higher than the [NII] line critical densities, the low-density limit [NII]-based SFR calibration systematically underestimates the SFR since [NII] emission is collisionally quenched. Finally, we investigate the relation between [NII] emission, SFR, and $n_e$ by comparing our observations to predictions from the MAPPINGS-III code.