AbstractAim Studies on habitat fragmentation of insect communities mostly ignore the impact of the surrounding landscape matrix and treat all species equally. In our study, on habitat fragmentation and the importance of landscape context, we expected that habitat specialists are more affected by area and isolation, and habitat generalists more by landscape context.Location and methods The study was conducted in the vicinity of the city of Göttingen in Germany in the year 2000. We analysed butterfly communities by transect counts on thirty‐two calcareous grasslands differing in size (0.03–5.14 ha), isolation index (2100–86,000/edge‐to‐edge distance 55–1894 m), and landscape diversity (Shannon–Wiener: 0.09–1.56), which is correlated to percentage grassland in the landscape.Results A total of 15,185 butterfly specimens belonging to fifty‐four species are recorded. In multiple regression analysis, the number of habitat specialist (n = 20) and habitat generalist (n = 34) butterfly species increased with habitat area, butz‐values (slopes) of the species–area relationships for specialists (z = 0.399) were significantly steeper compared with generalists (z = 0.096). Generalists, but not specialists, showed a marginally significant increase with landscape diversity. Effects of landscape diversity were scale‐dependent and significant only at the smallest scale (landscape context within a 250 m radius around the habitat). Habitat isolation was not related to specialist and generalist species numbers. In multiple regression analysis the density of specialists increased significantly with habitat area, whereas generalist density increased only marginally. Habitat isolation and landscape diversity did not show any effects.Main conclusions Habitat area was the most important predictor of butterfly community structure and influenced habitat specialists more than habitat generalists. In contrast to our expectations, habitat isolation had no effect as most butterflies could cope with the degree of isolation in our study region. Landscape diversity appeared to be important for generalist butterflies only.