The explosion took place as students were leaving the building on Saturday, with pictures on social media showing abandoned school bags in the street.
Most of those hurt were girls, a ministry of education spokeswoman said.
No-one has admitted carrying out the attack in Dasht-e-Barchi - an area often hit by Sunni Islamist militants.
The neighbourhood is home to many from the Hazara minority community, who are of Mongolian and Central Asian descent and are mainly Shia Muslims.
Almost exactly a year ago, a maternity unit at the local hospital was attacked, leaving 24 women, children and babies dead.
The exact target for Saturday's attack is unclear.
Reports from the city say it was busy with shoppers ahead of this year's celebrations for Eid al-Fitr next week.
Students were also streaming from the school. Najiba Arian, ministry of education spokeswoman, told Reuters news agency the government-run school was open to boys and girls.
Most of the those hurt were girls, who study in the second of three sessions, according to Arian.
Several witnesses described hearing three separate explosions, while one woman told AFP news agency she had seen "many bloodied bodies in dust and smoke".
"I saw a woman checking the bodies and calling for her daughter," the woman, Reza, said. "She then found her daughter's bloodstained purse after which she fainted and fell to the ground."
The European Union's mission in Afghanistan said on Twitter that "targeting primarily students in a girls' school, makes this an attack on the future of Afghanistan".
The attack comes against a backdrop of rising violence as the US looks to withdraw all its troops from the country by 11 September.