Protoplanetary disks around young stars are the sites of planet formation. While the dust mass can be estimated using standard methods, determining the gas mass - and thus the amount of material available to form giant planets - has proven to be very difficult. Hydrogen deuteride (HD) is a promising alternative to the commonly-used gas mass tracer, CO. We aim to examine the robustness of HD as tracer of the disk gas mass, specifically the effect of gas mass on the HD FIR emission and its sensitivity to the vertical structure. Deuterium chemistry reactions relevant for HD were implemented in the thermochemical code DALI and models were run for a range of disk masses and vertical structures. The HD J=1-0 line intensity depends directly on the gas mass through a sublinear power law relation with a slope of ~0.8. Assuming no prior knowledge about the vertical structure of a disk and using only the HD 1-0 flux, gas masses can be estimated to within a factor of 2 for low mass disks (M$_{rm disk} < 10^{-3}$ M$_odot$). For more massive disks, this uncertainty increases to more than an order of magnitude. Adding the HD 2-1 line or independent information about the vertical structure can reduce this uncertainty to a factor of ~3 for all disk masses. For TW Hya, using the radial and vertical structure from Kama et al. 2016b the observations constrain the gas mass to $6cdot10^{-3}$ M$_odot$ < M$_{rm disk} < 9cdot10^{-3}$ M$_odot$. Future observations require a 5$sigma$ sensitivity of $1.8cdot10^{-20}$ W m$^{-2}$ ($2.5cdot10^{-20}$ W m$^{-2}$) and a spectral resolving power R > 300 (1000) to detect HD 1-0 (HD 2-1) for all disk masses above $10^{-5}$ M$_odot$ with a line-to-continuum ratio > 0.01. These results show that HD can be used as an independent gas mass tracer with a relatively low uncertainty and should be considered as an important science goal for future FIR missions.