Kong Wei (孔緯) (died October 1, 895), courtesy name Huawen (化文), formally the Duke of Lu (魯公), was an official of the late Tang dynasty, serving as a chancellor during the reigns of Emperor Xizong and Emperor Xizong's brother Emperor Zhaozong. Background and early career Kong Wei's family was descended from the Spring and Autumn period philosopher Kong Qiu (Confucius). His great-granduncle Kong Chaofu () was a well-known official during the reign of Emperor Dezong, and his great-grandfather Kong Cenfu () and grandfather Kong Kui () also both served as imperial officials. His father Kong Wenru () served as a county secretary general, but died early. Kong Wei had at least two younger brothers, Kong Jiang () and Kong Jian (). As Kong Wenru died early, Kong Wei was raised by his uncles Kong Wenyu () and Kong Wenye (). As both Kong Wenyu and Kong Wenye served as regional governors, Kong Wei followed them to their assignments, and due to the friendships that Kong Wenyu and Kong Wenye had, Kong Wei became well known among the imperial officials. He passed the imperial examinations in the Jinshi class in 859, during the reign of Emperor Xuānzong, and therefore served as a copyeditor (校書郎, Xiaoshu Lang) at the Palace Library. When the former chancellor Cui Shenyou served as the military governor (Jiedushi) of Dongchuan Circuit (東川, headquartered in modern Mianyang, Sichuan), he invited Kong to serve on his staff. Kong later served on the staff of another former chancellor, Cui Xuan, when Cui Xuan served as the military governor of Huainan Circuit (淮南, headquartered in modern Yangzhou, Jiangsu). He then served under Cui Shenyou again at Hua Prefecture (華州, in modern Weinan, Shaanxi) and then Hezhong Circuit (河中, headquartered in modern Yuncheng, Shanxi). Under the recommendation of the chancellor Yang Shou, Kong was made the sheriff of Chang'an County, one of the two counties making up the Tang Dynasty capital Chang'an, and also served as a researcher at Hongwen Pavilion (). Later, Wang Duo, who was then the deputy chief imperial censor, recommended Kong to be an imperial censor with the title Jiancha Yushi (), and Kong was then made Libu Yuanwailang (), a low-level official at the ministry of rites (禮部, Lǐbu). The chancellor Xu Shang then recommended that he be made a scholar at Jixian Hall () as well as Kaogong Yuanwailang (), a low-level official at the minister