Human Rights Watch (HRW) has accused the Nigeria military of detaining more than 3,500 children over the last seven years.
The children, almost half of them girls and some as young as seven, are accused of having links to the Islamist Boko Haram militant group, the rights groups says in its report.
Many of them say were arrested after fleeing Boko Haram attacks on their villages in the north-east of the country.
They are detained without charge for months or years - crammed into military barracks and unable to contact the outside world.
Former detainees from Giwa military barracks in the north-eastern city of Maiduguri told HRW they experienced hunger and torture.
Some children said they had witnessed deaths of fellow inmates and soldiers sexually exploiting girls.
Smouldering ashes on the ground in Badu near Maiduguri, Nigeria - following a Boko Haram attack - July 2019
The military provided no formal education or rehabilitation activities for children at Giwa barracks, the report said.
Their only activities were prayer, watching television and informal lessons that some children provided for others, it said.
The overcrowded conditions also made physical activity impossible, and some children said they developed sores from restricted movement.
HRW has called on the authorities to immediately release all children in military custody.
The Nigerian military has yet to comment on the allegations.