A child's diet is an important determinant for later health, growth and development. In Denmark, most children in primary school bring their own packed lunch from home and attend an after-school care institution. The aim of the present study was to evaluate the food, energy and nutrient intake of Danish school children in relation to dietary guidelines and nutrient recommendations, and to assess the food intake during and outside school hours. In total, 834 children from nine public schools located in the eastern part of Denmark were included in this cross-sectional study and 798 children (95·7 %) completed the dietary assessment sufficiently (August–November 2011). The whole diet was recorded during seven consecutive days using the Web-based Dietary Assessment Software for Children (WebDASC). Compared with the food-based dietary guidelines and nutrient recommendations, 85 % of the children consumed excess amounts of red meat, 89 % consumed too much saturated fat, and 56 % consumed too much added sugar. Additionally 35 or 91 % of the children (depending on age group) consumed insufficient amounts of fruits and vegetables, 85 % consumed insufficient amounts of fish, 86 % consumed insufficient amounts of dietary fibre, 60 or 84 % had an insufficient Fe intake (depending on age group), and 96 % had an insufficient vitamin D intake. The study also showed that there is a higher intake of fruits and bread during school hours than outside school hours; this is not the case with, for example, fish and vegetables, and future studies should investigate strategies to increase fish and vegetable intake during school hours.