"We saw several children in there that had been burnt," Phillip Gathogo, a local resident, told reporters.
"I was just lucky to save one of them, but I heard that he later died. It was a very troubling and sad tragedy."
The blaze occurred at the Hillside Endarasha Academy in Nyeri, a primary boarding school for young students about 150 km (93 miles) from the capital Nairobi.
Government spokesperson Isaac Mwaura said the boys were in grades 4 to 8, putting their ages at about 9 to 13-years-old. He said in a statement the dormitory housed 156 students.
"We have lost 17 pupils in the fire incident while 14 are injured," police spokesperson Resila Onyango said. "Our team is at the scene at the moment."
Vice President Rigathi Gachagua said 70 pupils remained unaccounted for, although he added that some may have been taken home by their parents in the night.
Citizen Television said the fire had burnt the victims beyond recognition.
The cause of the fire was not immediately clear.
"Many children managed to jump out and get to safety, but we do not know how many were successful," Interior Minister Kithure Kindiki said while visiting the school.
‘HORRIFIC INCIDENT’
"The government assures full accountability for all whose action or inaction contributed to this tremendous loss," Kindiki later wrote on X.
He appealed for local residents who took in survivors to bring them back to the school so that they might receive medical help and counselling.
President William Ruto said he had told authorities to investigate what he called the "horrific incident" and said those responsible would be held to account.
Authorities have cordoned off the school and crime scene investigators have been sent there, the Interior Ministry said.
Calls by Reuters to the school’s main phone line went unanswered.
The school has a total 824 students comprising 422 girls and the rest boys. Of these, 160 girls are boarders while the rest are day scholars, Belio Kipsang, the Education Ministry’s Principal Secretary, said in a statement.
Kenya has a history of school fires, many of which have turned out to be arson.
Nine students were killed in September 2017 in a fire at a school in the capital Nairobi that the government attributed to arson.
In 2001, 58 schoolboys were killed in a dormitory fire at Kyanguli Secondary School outside Nairobi. In 2012, eight students were killed at a school in Homa Bay County in western Kenya.