Emperor Jin Gongdi 晉恭帝 (r. 418-419), personal name Sima Dewen 司馬德文, was the last emperor of the Jin dynasty 晉 (265-420). He was a brother of his predecessor, Emperor An 晉安帝 (r. 396-418). Before his accession to the throne, Sima Dewen was Prince of Langya 琅琊 and formally bore the titles of Minister of Education (situ 司徒) and overseer of the six imperial secretaries (lu shangshu liutiao shi 錄尚書六條事). He was mentally deficient and could therefore not carry out his functions.
When the rebel Huan Xuan 桓玄 (369-404) assumed the title of emperor, Sima Dewen was punished by demoting him to the status of District Duke of Shiyang 石陽縣公. During the rebellion, the two brothers resided in exile in Shouyang 壽陽.
In 418, the Counsellor-in-chief (xiangguo 相國) and Duke of Song 宋, Liu Yu 劉裕 (363-422), killed Emperor An and enthroned Sima Dewen as a puppet emperor. His empress hailed from the family Chu 褚, and the government chose the reign motto Yuanxi 元熙 "Originary Brilliance".
Political matters were fully in the hands of Liu Yu, who planned to take over the throne of the empire. This matter was announced to the emperor by Fu Liang 傅亮 (374-426), who urged the sovereign to resign (shanwei 禪位). Fu Liang also drafted the edict and had the emperor sign it. Apparently Sima Dewen was quite happy of being freed from his burden of reigning, and decided to write the edict on red paper, signaling a joyful event.
With his abdication, the Jin dynasty came to an end and was replaced by Liu Yu's Song dynasty, which is known in history as Liu-Song dynasty 劉宋 (420-479), in order to discern it from the great Song dynasty 宋 (960-1279).
Sima Dewen was given the title of Prince of Lingling 零陵. He resided in Moling 秣陵 close to present-day Nanjing 南京, Jiangsu, and was allowed to make use of imperial state coaches and state robes. He rarely went out and dedicated his life to Buddhism. In 421, Liu Yu ordered to kill the former emperor. He was buried in Mound Chongping 沖平陵. His posthumous title is Emperor Gong 恭帝 "the Respectful".