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 them 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.
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.” -BBC