Janaka’s father, Nimi, king of Mithila, was childless and asked the venerable brahmin Vasishtha to preside over a ritual (yajna) for a son. Vasishtha was preoccupied with another ritual and asked the king to wait. King Nimi left without making any commitment and then found another priest named Gautama to perform the yajna. When Vasishtha finished his other business, he went to King Nimi, who told the priest that the ritual had already been performed. Vasishtha became so angry that he pronounced a death curse on the king, dooming him to be without a body (videha). Nimi died instantly. He had no heir, so the rishis (seers) immediately churned (mathana) a son from his corpse. The son was named Siradhvaja, but because of the churning he acquired the name of Mithi (“churned”) Janaka, and his dynasty would be named Videha.
Now Janaka, king of Mithila, was also childless. One day he found a child born from the furrows of a plowed field. A voice from heaven told him that this child was Sita and that she was his daughter.
Janaka became a great scholar. He was tested on one occasion by Sulabha, a great shamaness who changed into a beautiful woman and then entered into his soul while they discussed philosophical subjects. She left ashamed of herself and convinced that Janaka was both wise and pure. Janaka once clarified the doubts of Vyasa’s son Suka when even the great sage Vyasa had not been able to help. One account said the Janaka was an incarnation of all good qualities. He became Rama’s father-in-law when Rama married Sita.
The Padma Purana has two long chapters about Janaka leaving his body when he was ready to die through his own yogic powers. He was met by a divine chariot (vimana) but had a brief stop in hell. After learning from Kala (time, god of death) of the torments of hell’s inmates, Janaka chanted “Ram, Ram” (japa) for them and gained their release. Then he asked Kala why he had stopped briefly in hell. Kala told him that he was the most righteous man of his age, with the most merit (punya) but that he had once prevented a cow from eating grass. That sin was now atoned for, and Janaka resumed his journey to heaven.