Nimi (Sanskrit: निमि, romanized: Nimi) is a king of the Suryavamsha (Solar dynasty) featured in Hindu mythology. He is considered to be the first king of the Videha kingdom and is regarded to be the ancestor to the Janaka lineage of Mithila. Nimi is the grandson of Manu, and a son of Ikshvaku.
 Once, Nimi performed a yajña and invited Sage Vasishtha to be the main priest to conduct the ceremony. However, the sage had already committed to conduct a yajña for Indra, and he told Nimi that he would officiate as the head priest after having conducted Indra's yajña. Nimi went away without replying. Sage Vashistha was under the impression that King Nimi has assented to wait for him.
 The sage conducted Indra's yajña and rushed to preside at Nimi's yajña only to find that the yajña was already being conducted by Gautama. Sage Vasishtha got angry and cursed King Nimi that "he would cease to live in corporal form" while the king was asleep. Thus, King Nimi was left without his body to heaven with Indra, and stayed there for 9,000,000 years. After the yajña was conducted successfully, the priests asked the gods to return King Nimi to his corporal form. However, he refused to return to his bodily form. The account of Nimi is described by Rama to Lakshmana in the Uttara Kanda of Ramayana.
 This episode is also detailed in the Vishnu Purana.
 In several traditions, a righteous and edifying Videhan King Nimi or Nemi is mentioned, who travels to heaven and hell in a celestial chariot. The story is mentioned in one text of the Pāli Canon, and two Pāli post-canonical texts. The name Nimi or Nemi is explained as "he brings the lineage full circle like the rim (Pali: nemi) of a carriage wheel". The story relates that a certain King Makhadeva tells his barber that the latter should warn him as soon as the king has his first grey hair, a common memento mori motif found in ancient Indian literature, which goes back to the ancient Indian conception of stages of life. Later on, when his first hairs go grey, and his barber tells him about that, the king goes forth to lead a spiritual life as a hermit, but not before he entrusts his son to do the same when his hair goes grey. The former king is later reborn in a heavenly world. He sees that his descendants all follow the same tradition of becoming hermits when they became old. He then decides to be reborn as the next descendant of the same dynasty, and has the name King Nimi. The story then goes on to say that this king is able to travel to heaven and hell at the invitation of the god Sakka. At the end of the story, King Makhadeva, later reborn as Nimi, is identified as a previous birth of the Buddha, and the barber and heavenly charioteer are identified as the disciple Ānanda.
 The story is mentioned in many other early Buddhist texts, both canonical and post-canonical. Translator C. A. F. Rhys Davids compared the legend with Dante's Inferno. The story of King Nimi visiting heaven and hell is iconic in traditional Thai art, and is easily recognizable for the average Thai person. This story, as well as many similar stories that deal with cakravartin kings, attempts to establish that the spiritual life of renunciation is superior to the worldly life, and the solitary life superior to a married life. Moreover, Asian religion scholar Naomi Appleton argues that there is a connection between the stories of the Videhan renouncing kings and the ideal of the solitary Buddha in Buddhism. Solitary Buddhas are often depicted renouncing their worldly life because of certain signs in their environment or on their body, as in the case of Makkhadeva. Finally, according to the scholar Padmanabh Jaini, the story may also have influenced how Buddhist cosmology was interpreted.
 In post-canonical Pāli works, the belief is expressed that King Nimi belongs to a long line of Kings descending from Mahāsammata, the first king of humankind. The Buddha is believed to be a descendant of the same dynasty.
 In Jain texts, a similar motif as in Buddhist texts can be found, of a king called Nami.