Emperor Jin Andi 晉安帝 (r. 396-418), personal name Sima Dezong 司馬德宗, was one of the last emperors of the Jin dynasty 晉 (265-420). He was a son of Emperor Xiaowu 晉孝武帝 (r. 372-396) and Lady Chen 陳夫人. Historians say he was mentally deficient in such a way that he was unable to formulate sentences and to discern cold from warm. He nevertheless obtained the title of Heir Apparent (huang taizi 皇太子) in 387, and in 396 succeeded his father to the throne. He was married to a girl from the Wang family 王.
Regency was taken over by his uncle Sima Daozi 司馬道子 (364-403), the Prince of Guiji 會稽. Yet the latter ruled in an authoritarian style and was deemed arrogant, so everyone hated him.
In 398, the empress' brother Wang Gong 王恭 (d. 398) and Huan Xuan 桓玄 (369-404) rose in rebellion and threatened the capital Jiankang 建康 (present-day Nanjing 南京, Jiangsu). While Wang Gong was soon murdered by his followers, Huan Xuan rose to prominence and threatened the heartland of the Jin empire. Only in 402, the throne issued an edict urging everyone to fight the rebel. The campaign was taken over by Sima Daozi's son, Sima Yuanxian 司馬元顯 (382-402), as the area commander-in-chief (da dudu 大都督). The emperor, clothed in armour, feasted the princely commander, but his army was utterly defeated by the rebels. Huan Xuan entered the capital city and killed Sima Daozi and his son. A year later, the rebel assumed the title of emperor, formally degraded Sima Dezong to the status of Prince of Pinggu 平固, and ordered him to reside in Xunyang 尋陽 (today's Jiujiang 九江, Jiangxi).
In 404, Martial General (jianwu jiangjun 建武將軍) Liu Yu 劉裕 (363-422) was ready to attack the usurper. Huan Xuan took the former emperor as a hostage and fled to Jiangling 江陵 (today's Shashi 沙市, Hubei). Liu Yu pursued him, attacked Jiangling and deafeated Huan Xuan. The rebel died, and Liu Yu brought Sima Dezong back to Jiankang. For his merits, Liu Yu was made supreme commander of the imperial armies and regional inspector (cishi 刺史) of the provinces of Qingzhou 青州, Xuzhou 徐州, and Yanzhou 兗州. Moreover, he was appointed regent of the empire.
In 418, Liu Yu had Sima Dezong killed and enthroned his younger brother Sima Dewen 司馬德文, who is known as Emperor Gong 晉恭帝 (r. 418-419). Dezong's posthumous title is Emperor An 安帝 "The Peaceful". He was buried in Mound Xiuping 休平陵 close to Nanjing.