0753 GMT January 19, 2020
The wooden structure at Precious Talent Top School collapsed just minutes after the start of the school day on Monday, BBC reported.
Dozens of people were injured and have been taken to hospital in the city. Emergency services are at the scene.
Rescuers have reportedly had difficulty getting to the school because of large crowds that have gathered nearby.
"So far we can confirm that we have seven fatalities and 57 others are in hospital," a government spokesman told reporters outside the school in Dagoretti.
The school's director, Moses Ndirangu, blamed the collapse on the construction of a nearby sewer pipe which he said may have weakened the foundations of the building.
The incident happened shortly before 07:00 local time (04:00 GMT) and dozens of children were quickly rushed away from the scene.
The Kenya Red Cross transferred some children to the Kenyatta National Hospital.
The first floor of the building collapsed and trapped the children below, local politician John Kiarie told the NTV Kenya television channel.
Angry locals have complained about the slow emergency response, the BBC's Ferdinand Omondi reported from Nairobi.
Images on social media show hundreds of residents gathered around the site as rescuers search through the rubble.
Books, desks and chairs can be seen amongst the debris.
The government has opened an investigation into the cause of the accident.
"I had just dropped my son to school and heard screams on my way back," Margaret Muthoni, whose four-year-old son was injured, told AFP news agency.
"I am just lucky my son survived," she added.