Context. Planet formation is closely related to the structure and dispersal of protoplanetary disks. A certain class of disks, called transition disks, exhibit cavities in dust images at scales of up to a few 10s of AU. The formation mechanism of the cavities is still unclear. The gas content of such cavities can be spatially resolved for the first time using the Atacama Large Millimeter/submillimeter Array (ALMA). Aims. We develop a new series of models to simulate the physical conditions and chemical abundances of the gas in cavities to address the question whether the gas is primarily atomic or molecular inside the dust free cavities exposed to intense UV radiation. Molecular/atomic line emission by carbon monoxide (CO), its isotopologues ( Methods. We use a thermo-chemical model, which calculates the radiative transfer both in lines and the continuum, and solves for the chemical abundances and gas temperature. The model is based on our previous work, but includes several improvements. We study the dependence of CO abundances and lines on several parameters such as gas mass in the cavity, disk mass and luminosity of the star.Results. The gas can remain in molecular form down to very low amounts of gas in the cavity (∼1% of M Earth ). Shielding of the stellar radiation by a dusty inner disk ("pre-transition disk") allows CO to survive down to lower gas masses in the cavity. The column densities of H 2 and CO in the cavity scale almost linearly with the amount of gas in the cavity down to the mass where photodissociation becomes important. The main parameter for the CO emission from cavity is the gas mass. Other parameters such as the outer disk mass, bolometric luminosity, shape of the stellar spectrum or PAH abundance are less important. Since the CO pure rotational lines readily become optically thick, the CO isotopologues need to be observed in order to quantitatively determine the amount of gas in the cavity. Determining gas masses in the cavity from atomic lines (Conclusions. A wide range of gas masses in the cavity of transition disks (∼4 orders of magnitude) can be probed using combined observations of CO isotopologue lines with ALMA. Measuring the gas mass in the cavity will ultimately help to distinguish between different cavity formation theories.