Moalim Nur Aden, another witness, said: "The kids would not be recognised because the bomb cut them into pieces. It was a very awful thing to happen to children going to school."
Faisal Haji, a tribal elder, said: "We are grieving now with the parents ... these children are innocent".
It is not clear who or what was the target of the explosion, which came a day after the Union of Islamic Courts threatened to carry out more attacks to force Ethiopian troops out of the country.
"I think the bomb targeted Ethiopian and Somali government troops who frequently use the road," Ibrahim Mohamed, who lives near the school, told Reuters news agency.
The movement was pushed out of central and southern Somalia by Ethiopian forces supporting troops from the interim government.
Mogadishu is hosting government-sponsored talks aimed at reconciling the feuding factions and tightening Abdullahi Yusuf Ahmed, the president's grip on power.
The latest attempt at reconciliation is being supported by the UN and Western powers but being boycotted by the Union of Islamic Courts.
Instead, they plan to launch separate talks in the Eritrean capital Asmara on September 1.
Meanwhile on Saturday, fighters had attacked a hotel hosting the peace delegates, wounding two, and casting doubt on the prospects for peace in Somalia.
Somali and Ethiopian troops, and at least 1,500 AU peacekeepers have been unable to halt attacks that have moved from direct confrontation to bomb blasts and guerrilla-style tactics against government targets.
Last week, aid groups had reported that 1.5 million people were in need of aid supplies over the past eight months, an increase of 50 per cent.