The Mingshi 明史 "History of the Ming" is the official dynastic history (zhengshi 正史) of the Ming dynasty 明 (1368-1644). Over time it had become common for a newly established dynasty to compile an official history of the preceeding dynasty. The compilation of the Mingshi started in 1679 and it was only finished in 1739 when it was submitted to the throne by Zhang Tingyu 张廷玉. The first imperial order to compile the history of the Ming was issued in 1645, one year after theManchus' conquest of Beijing but at such an early point of time it was not possible to collect material and sources sufficient for such a task. Only in 1679 a Compilation Office for the History of the Ming (Mingshiguan 明史馆) was established. The compilation team was supervised by Xu Yuanwen 徐元文 and led by Ye Fang'ai 叶方蔼, Zhang Yushu 张玉书, Tang Bin 汤斌 and Xu Qianxue 徐干学. One of the most important contributors was Wan Sitong 万斯同. In 1691 the draft version with a length of 416 juan "scrolls" was finished, the Mingshigao 明史稿.

But because it was lacking completeness and suffered from inconsistencies it was not submitted to the throne at that date.
Three years later a team of scholars took over the refining: Zhang Yushu, Xiong Cilü 熊赐履, Chen Tingjing 陈廷敬, and Wang Hongxu 王鸿绪. Again, Wan Sitong and Qian Mingshi 钱名世 were asked to support the editors. In 1702 Wan Sitong died and Wang Hongxu personally trimmed and polished the text. The first part to be ready were the normal and collective biographies (liezhuan 列传) which were submitted to the throne in 1714. The treatises (zhi 志) and tables (biao 表) still had to be condensed, and together with the biographies were submitted in 320 chapters (juan) in 1723, as the so-called Hengyun shanren Mingshi gao 横云山人明史稿 "Draft to a history of the Ming dynasty by the Man from Mt. Horizontal Clouds [i. e. Wang Hongxu]". The draft comprised 320 juan: 9 juan of imperial biographies (benji 本纪), 77 juan of treatises, tables in 9 juan, and normal and collective biographies in 205 juan.

Basing on this version Zhang Tingyu and Zhu Shi 朱轼 developed a final version submitted to the throne in 1739. It was printed by the imperial print office in the Wuying Hall 武英殿 of the Imperial Palace under the title of Mingshi. The whole compilation process had taken 95 years for completion, which is the longest necessary for any official book.

The Mingshi consists of 332 juan of which 24 are imperial biographies, 75 treatises, 13 tables, and 220 normal and collective biographies.

The primary sources for the compilation were official documents like the veritable records of the Ming Mingshilu 明实录, archival material, the so-called dibao 邸报 "Peking gazette", a local history of the imperial capital, the Da-Ming huidian 大明会典 "Statutes of the Great Ming", memorials to the throne, local gazeteers, biographies, but also unofficial material like privately written histories or literary sources.