Court-case fiction (gong'an xiaoshuo 公案小說) refers to a genre of classical Chinese fiction that primarily deals with legal cases from everyday life, especially criminal trials and the correction of wrongful convictions.
This genre first arose in the huaben 話本 storytelling texts of the Song period 宋 (960-1279), in works such as Cuo zhan Cui Ning 錯斬崔寧 "The wrongful execution of Cui Ning" and Song Sigong da nao Jinhun Zhang 宋四公大鬧禁魂張 "Song Sigong's uproar against Zhang the Soul-Restrainer". During the Southern Song period 南宋 (1127-1279), Nai Deweng's 耐得翁 (fl. 1235) Ducheng jisheng 都城紀勝 classified "storytelling" (shuo hua 說話) into four categories or "schools" (si jia 四家), with the fiction categories of romantic tales (yanfen 煙粉), supernatural tales (lingguai 靈怪), tales of marvels (chuanqi 傳奇), and court-case stories (gong'an 公案).
Although Song-period court-case huaben featured upright officials (qingguan 清官) to adjudicate cases, they could still voice the grievances and injustices endured by ordinary people and expose the incompetence and corruption of officialdom.
During the Yuan 元 (1279-1368) and Ming 明 (1368-1644) periods, court-case fiction further evolved into works explicitly aimed at praising such "upright officials", for example the collections Bao Xiaosugong baijia gong'an yanyi 包孝肅公百家公案演義 and Hai Gangfeng Xiansheng ju guan gong'an 海剛峰先生居官公案, which are specialised collections of court-case stories. However, their role in revealing social injustice gradually diminished, and instead they focused on encouraging people to have greater faith in “upright officials” and the emperor.
By the late Qing period 清 (1644-1911), court-case fiction merged with chivalric fiction to form "chivalric court-case fiction" (xiayi gong'an xiaoshuo 俠義公案小說). Compared with this later form, the Song-period huaben court-case stories are notable for their realistic depiction of everyday life, intricate plots, detailed narration, and convincing characterization. In contrast, chivalric court-case fiction often fabricates characters and events, exhibits crude writing, loose structure, and generally possesses limited artistic value.
The most renowned figures of court-case fiction are Justice Bao 包公, Justice Shi 施公, and Justice Peng 彭公, among others. Stories or plays depicting their wit and sense of justice are commonly referred to as Bao gong'an 包公案, Shi gong'an 施公案, and Yu gong'an 于公案. These are three main traditional long-form narrative repertoires in Chinese performing arts (quyi 曲藝). They tell stories of upright officials who stand up for the people, correct injustices, and settle legal cases. These stories have been widely performed in storytelling styles such as pingshu 評書, pinghua 評話, and gushu 鼓書, with the first two particularly popular.
Bao gong'an 包公案, also known as Longtu gong'an 龍圖公案 or simply Bao gong 包公, recounts tales of the Song-period official Bao Zheng 包拯 (999-1062) judging cases, punishing evil, and rooting out corruption. The well-known novel Sanxia wuyi 三俠五義 is said to have been adapted from storytelling versions of the Longtu gong'an performed by the Qing-period storyteller Shi Yukun 石玉昆 (c. 1810-1871). The content of the Bao gong'an varies across regional performance traditions. Northern pingshu versions often include episodes from the part Xiao wuyi 小五義 and Xu xiao wuyi 續小五義, while the Baogong'a pinghua version of Suzhou 蘇州 weaves stories from the Yangjiajiang 楊家將 cycle.
Shi gong'an 施公案 tells of Shi Shilun 施仕倫 (1659-1722), a magistrate of Yangzhou 揚州 during the Kangxi reign-era 康熙 (1662-1722) of the Qing period, and his adjudication of legal cases. In the narrative, Huang Tianba 黃天霸, originally a bandit hero, is captured and then joins Shi Shilun, subsequently turning against his former sworn brothers and other outlaw heroes. As a result, both Shi and Huang gain the favour of the Kangxi Emperor 康熙帝 (r. 1661-1722) and are rewarded with high office and wealth. The novel Shi gong'an was adapted from performing arts traditions, and it portrays Shi Shilun in an idealised manner, despite his rise to power being linked to the violent suppression of outlaw figures.
Other collections of court-case stories are Hai gong'an 海公案 by Li Chunfang 李春芳 (1510-1584; cases of Hai Rui 海瑞), Yu gong'an 于公案 (early 19th cent., the cases of the two Yu Chenglong 于成龍) amd Peng gong'an 彭公案 by Yang Yidian 楊挹殿 (1891; the cases of Peng E 彭鵬).