Three Earth-sized exoplanets were recently discovered close to the habitable zone of the nearby ultracool dwarf star TRAPPIST-1 (ref. 3). The nature of these planets has yet to be determined, as their masses remain unmeasured and no observational constraint is available for the planetary population surrounding ultracool dwarfs, of which the TRAPPIST-1 planets are the first transiting example. Theoretical predictions span the entire atmospheric range, from depleted to extended hydrogen-dominated atmospheres. Here we report observations of the combined transmission spectrum of the two inner planets during their simultaneous transits on 4 May 2016. The lack of features in the combined spectrum rules out cloud-free hydrogen-dominated atmospheres for each planet at ≥10σ levels; TRAPPIST-1 b and c are therefore unlikely to have an extended gas envelope as they occupy a region of parameter space in which high-altitude cloud/haze formation is not expected to be significant for hydrogen-dominated atmospheres. Many denser atmospheres remain consistent with the featureless transmission spectrum—from a cloud-free water-vapour atmosphere to a Venus-like one.