The explosion took place outside the northeast Nigerian town of Ngala, near the border with Cameroon, militiamen said. The children were playing with a disused grenade that exploded, killing them.
Anti-jihadist militiaman Umar Kachalla said the children picked up the explosive while herding in a field outside the town and it exploded in their hands while they were playing with it.
Two of them died on the spot and the other three died in a hospital in Mada, Cameroon.
Umar Ari, another militiaman, told a similar story about the incident, which occurred on Thursday.
The Boko Haram jihadist group seized Ngala and Gamboru in August 2014.
Following a months-long offensive, Nigerian forces recaptured the two towns in September 2015.
In the surrounding countryside, he told Ari, there are unexploded bombs and grenades from the conflict, and many children have been injured or killed.
An explosive device exploded on a crowded bridge linking Gamboru and Fotokol in December 2019, killing nine people and injuring 26 others.
Boko Haram insurgents gave some children a toy disguised as a grenade as a gift, residents claim.