Human rights chief Michelle Bachelet also called on countries to take responsibility for their citizens and take them back them if not charged.
She said that children in particular had suffered “grievous violations” of their human rights.
The last IS strongholds fell in March and some 55,000 people are being held.
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…