Pei Xuan is a fictional character in Water Margin, one of the Four Great Classical Novels in Chinese literature. Nicknamed "Iron Faced Magistrate's Scribe", he ranks 47th among the 108 Stars of Destiny and 11th among the 72 Earthly Fiends.
Pei Xuan, a native of Jingzhao Prefecture (京兆府; around present-day Xi'an, Shaanxi), is a kongmu (孔目; magistrate's scribe) in his hometown. He is known for being uncompromising in upholding justice, incorruptible before bribes and fearless of coercions. These attributes earn him the nickname "Iron Faced Magistrate's Scribe". Besides being well-versed in the law of the Song empire, Pei Xuan, who has a chubby face, is an expert in swordsmanship and likes traditional arts.
Pei Xuan's no-nonsense approach in handling litigation cases at last gets him into trouble with higher officials. They falsely accuse him of insubordination and gets him sentenced to exile in Shamen Island (沙門島; present-day Changdao County, Shandong). Along the way, Pei Xuan and his escorts pass by Yinma River (飲馬川; in present-day Ji County, Tianjin), where they are intercepted by a bandit gang led by Deng Fei and Meng Kang. Freed by the two, Pei Xuan impresses them with his aplomb and upright personality that they made him their leader.
Dai Zong of Liangshan incidentally comes to know Yang Lin when he is in Jizhou by order of Song Jiang to locate Gongsun Sheng to fetch him back to the stronghold. Gongsun has been away too long to visit his mother. Together, Dai and Yang pass by Yinma River (飲馬川; in present-day Ji County, Tianjin), where they are blocked by Deng Fei, Meng Kang and their men. It turns out that Yang and Deng are acquaintances. They are introduced to Pei Xuan, who accepts Dai's invitation to merge his band into that of Liangshan.
Pei Xuan is put in charge of deciding on rewards and punishments after the 108 Stars of Destiny came together in what is called the Grand Assembly. He participates in the campaigns against the Liao invaders and rebel forces in Song territory following amnesty from Emperor Huizong for Liangshan,
In the attack on Jingnan (荊南; around present-day Jingzhou, Hubei) in the campaign against Wang Qing, Pei Xuan, Xiao Rang and Jin Dajian are captured by the enemy. The three refused to surrender and divulge any information under torture. They are freed when Xiao Jiasui and others revolt against Wang, causing Jingnan to fall.
Pei Xuan is one of the few Liangshan heroes who survives all the campaigns. Although given an official position, he declines it and returns to Yinma River with Yang Lin to resume the life of a bandit.