The , also sometimes read as or , is an early Japanese chronicle of myths, legends, hymns, genealogies, oral traditions, and semi-historical accounts down to 641 concerning the origin of the Japanese archipelago, the , and the Japanese imperial line. It is claimed in its preface to have been composed by Ō no Yasumaro at the request of Empress Genmei in the early 8th century (711–712), and thus is usually considered to be the oldest extant literary work in Japan.
The myths contained in the as well as the are part of the inspiration behind many practices and unified "Shinto orthodoxy". Later, they were incorporated into Shinto practices such as the purification ritual.

Composition
It is believed that the compilation of various genealogical and anecdotal histories of the imperial (Yamato) court and prominent clans began during the reigns of Emperors Keitai and Kinmei in the 6th century, with the first concerted effort at historical compilation of which we have record being the one made in 620 under the auspices of Prince Shotoku and Soga no Umako. According to the Nihon Shoki, the documents compiled under their initiative were the Tennōki (, also Sumera-mikoto no fumi) or the "Record of the Emperors", the Kokki (, also Kunitsufumi) or the "National Record", and other "fundamental records" (, hongi or mototsufumi) pertaining to influential clans and free subjects. Out of these texts, only the Kokki survived the burning of Soga no Emishi's estate (where these documents were kept) during the Isshi incident of 645, and was itself apparently lost soon after.

The Kojiki preface indicates that leading families also kept their own historical and genealogical records; indeed, one of the reasons it gives for the compilation of the Kojiki is the correction of errors that had supposedly crept into these documents. According to the preface, Emperor Tenmu (reigned 673–686) ordered the review and emendation of clan documents and commissioned a certain court attendant (toneri) of exceptional memory named Hieda no Are to memorize records and oral traditions concerning the imperial lineage. Beyond this memorization, nothing occurred until the reign of Empress Genmei (reigned 707–715), who on the 18th of the 9th month of 711 (Wadō 4) ordered the courtier Ō no Yasumaro to record what had been learned by Hieda no Are. He finished and presented his work to Empress Genmei on the 28th of the 1st month of 712 (Wadō 5).

Purpose
The Kojiki is a collation of different traditions woven into a single "official" mythology, made in an attempt to justify the rule of the imperial Yamato polity and at the same time to subsume different interest groups under its wing by giving them a place and an interest in the national genealogy-mythology. Apart from furthering the imperial agenda, an increased interest in the nation's origins in reaction to the influx of foreign culture and the need for an authoritative genealogical account by which to consider the claims of noble families and to reorganize them into a new system of ranks and titles are also possible factors for its compilation.
The Kojiki narrative establishes the Yamato line's right to rule via myth and legend, portraying it as the progeny of heavenly deities and the rightful heir to the land of Japan. A good part of the latter portion of the text is spent recounting various genealogies which served not only to give the imperial family an air of antiquity (which may not necessarily reflect historical reality), but also served to tie, whether true or not, many existing clans' genealogies to their own. Regardless of the work's original intent, it finalized and possibly even formulated the framework by which Japanese history was examined in terms of the reign of emperors.
In contrast to the Nihon Shoki (compiled 720), the first of six histories commissioned by the imperial court, which was modeled on Chinese dynastic histories and was intended to be a national chronicle that could be shown with pride to foreign envoys, the Kojiki is inward looking, concerned mainly with the ruling family and prominent clans, and is apparently intended for internal consumption. Whereas the Nihon Shoki uses a variety of source documents (including Chinese texts), the Kojiki is apparently based on sources handed down within the court.





