Context. Ionized outflows in active galactic nuclei (AGNs) are thought to influence their nuclear and local galactic environment. However, the distance of the outflows with respect to the central engine is poorly constrained, which limits our understanding of their kinetic power as a cosmic feedback channel. Therefore, the impact of AGN outflows on their host galaxies is uncertain. However, when the density of the outflows is known, their distance can be immediately obtained from their modeled ionization parameters. Aims. We perform a theoretical study of density diagnostics of ionized outflows using absorption lines from metastable levels in Be-like to C-like cosmic abundant ions. Methods. With the new self-consistent PhotoIONization (PION) model in the SPEX code, we are able to calculate detailed level populations, including the ground and metastable levels. This enables us to determine under what physical conditions the metastable levels are significantly populated. We then identify characteristic lines from these metastable levels in the 1−2000 Å wavelength range. Results. In the broad density range of n H ∈ (10 6 , 10 20 ) m −3 , the metastable levels 2s2p ( 3 P 0−2 ) in Be-like ions can be significantly populated. For B-like ions, merely the first excited level 2s 2 2p ( 2 P 3/2 ) can be used as a density probe. For C-like ions, the first two excited levels 2s 2 2p 2 ( 3 P 1 and 3 P 2 ) are better density probes than the next two excited levels 2s 2 2p 2 ( 1 S 0 and 1 D 2 ). Different ions in the same isoelectronic sequence cover not only a wide range of ionization parameters, but also a wide range of density values. On the other hand, within the same isonuclear sequence, those less ionized ions probe lower density and smaller ionization parameters. Finally, we reanalyzed the high-resolution grating spectra of NGC 5548 observed with Chandra in January 2002 using a set of PION components to account for the ionized outflow. We derive lower (or upper) limits of plasma density in five out of six PION components based on the presence (or absence) of the metastable absorption lines. Once atomic data from N-like to F-like ions are available, combined with the next generation of spectrometers that cover both X-ray and UV wavelength ranges with higher spectral resolution and larger effective areas, tight constraints on the density and thus the location and kinetic power of AGN outflows can be obtained.