Djamila Boutoutaou, 29, told the court in Baghdad that she had left France with her husband, Mohammed Nassereddine, on holiday but discovered that he was a jihadist when she arrived in Turkey.
Boutoutaou, who is of Algerian origin, said her husband and another man locked her in a cellar with her two children, Abdallah and Khadija, before forcing her to join IS and live in the "caliphate" straddling Syria and Iraq that the jihadists proclaimed in 2014.
Her husband was killed near the former IS stronghold of Mosul and Abdallah died in an airstrike, she told the court.
Surrendered to Kurds
After his death, neighbours took her to Tal Afar, west of Mosul, where she and her neighbour's wife surrendere to the Iraqi Kurd peshmerga fighters.
Iraqi courts have sentenced a number of foreign women to life in prison after finding they had joined IS.
Two Russian women, both with babies, were sentenced by the same court.
Several dozen Turkish women and a German have been sentenced to death over the last few months.
But another French woman, Melina Boughedir, was jailed for seven months in February, having been charged with illegal residency in Iraq rather than terror-related offences.
About 20,000 people were arrested in the Iraqi counter-offensive against IS.