After the war Rama tells Sita before the assembly that he fought for his honour, not for her; she answers him and walks into a pyre, and Agni himself carries her out unburnt; later tellings say the woman in Lanka was only her shadow and the real Sita had waited in the fire.
Valmiki Ramayana, Yuddha Kanda 117 to 120 (Griffith)
Pan-India · LankaAll traditions
After the war Sita is brought to Rama before the army. He tells her he fought to clear his name, not for love of her, and she may go where she likes. She answers him: her heart was always his, and what her body suffered in another's power was not her doing. She asks Lakshmana to build a pyre, walks round Rama, prays to Agni to protect her if she is true, and goes into the flames. The gods appear and Brahma tells Rama he is Narayana and Sita is Lakshmi. Agni rises from the fire holding Sita unharmed and gives her back, pure; Rama says he never doubted her, but the world had to see.
Later tellings take the pain out of it. In the Kurma Purana Agni hides the real Sita before Ravana comes and leaves a double, who is burnt away in the ordeal. In the Adhyatma Ramayana Rama himself asks Sita to live in the fire for a year and leave her shadow in the hut. Tulsidas follows this. Some Puranas give the shadow a life of her own, ending as Draupadi.