The UN says tens of thousands of Islamic State fighters and family members being held in Iraq and Syria must be tried or released.
Human rights chief Michelle Bachelet also called on countries to take responsibility for their citizens and take them back if not charged.
The last IS strongholds fell in March and some 55,000 people are being held, including thousands of foreigners.
But many nations have shown reluctance to bring their citizens back.
The countries fear prosecutions of IS fighters may be difficult and public opinion is often strongly against repatriation.
Some countries have also refused to recognise the children of IS members born in Syria and Iraq as citizens, despite their parents having nationality.
Ms Bachelet said that children in particular had suffered "grievous violations" of their human rights.
What has Ms Bachelet said?
The UN High Commissioner for Human Rights said there should be no doubt about what must happen to those being detained.
"Accountability through fair trials protects societies from future radicalisation and violence," she said, adding that continuing to detain individuals not suspected of crimes was not acceptable.
She added: "Foreign family members should be repatriated, unless they are to be prosecuted for crimes in accordance with international standards."
Ms Bachelet highlighted in particular the plight of children born to IS fighters, reported to number about 29,000.
"States should provide the same access to nationality for children born to their nationals in conflict zones as is otherwise applicable.
"To inflict statelessness on children who have already suffered so much is an act of irresponsible cruelty," she said.
Who are the captives and where are they being held?
A vast number are at al-Hol camp in north-eastern Syria, which has seen a huge increase since the collapse of the last IS strongholds in Syria.
About 1,000 foreign IS fighters were captured by the US-backed Syrian Democratic Forces but several hundred have already been transferred to Iraq for trial. Those remaining are mostly family members.
The UN says there are about 29,000 children of foreign IS fighters in Syria, 20,000 of them from Iraq, but overall there are about 50 nationalities.
France, Russia, Morocco, Saudi Arabia and the Netherlands have taken back some children. from a "bleak and complicated'' situation at a Syrian refugee camp.
But many nations have shown unwillingness to allow repatriation.
Researchers estimate that more than 40,000 foreigners from 80 countries joined IS in Iraq and Syria between April 2013 and June 2018.
Iraq has offered to try all foreign fighters captured in Syria. since being transferred.
What is al-Hol like?
Ms Bachelet said conditions there were "deeply substandard".
The camp has seen an increase from 11,000 people to more than 70,000 following the collapse of the last IS bastion at Baghouz.
The BBC's Quentin Sommerville visited in April and said it appeared "ready to burst".
He said hundreds of children brought from Baghouz had died and the rest were at risk from sickness and disease.
Iraq was preparing camps on the other side of the border to take back its citizens but the fate of other women and children remained unanswered, he reported.