How many dimensions (trait-axes) are required to predict whether two species interact? This unanswered question originated with the idea of ecological niches, and yet bears relevance today for understanding what determines network structure. Here, we analyse a set of 200 ecological networks, including food webs, antagonistic and mutualistic networks, and find that the number of dimensions needed to completely explain all interactions is small ( < 10), with model selection favouring less than five. Using 18 high-quality webs including several species traits, we identify which traits contribute the most to explaining network structure. We show that accounting for a few traits dramatically improves our understanding of the structure of ecological networks. Matching traits for resources and consumers, for example, fruit size and bill gape, are the most successful combinations. These results link ecologically important species attributes to large-scale community structure.