The Duke Yansheng, literally "Honorable Overflowing with Wisdom", sometimes translated as Holy Duke of Yen, was a Chinese title of nobility. It was originally created as a marquis title in the Western Han dynasty for a direct descendant of Confucius.

From the Western Han dynasty to the mid-Northern Song dynasty, the title underwent several changes in its name, before it was finally settled as "Duke Yansheng" in 1005 by Emperor Renzong of the Northern Song dynasty. Kong Zongyuan, a 46th-generation descendant of Confucius, became the first person to hold the title "Duke Yansheng". The dukes enjoyed privileges that other nobles were denied, such as the right to tax their domain in Qufu while being exempt from imperial taxes. Their dukedom had its own judicial system and the legal capacity to mete out capital punishment, although such sentences had to be ratified by the imperial court.

In 1935, the Nationalist government of the Republic of China converted the Duke Yansheng title to a political office, "Dacheng Zhisheng Xianshi Fengsi Guan" (), which simply means "Ceremonial Official to Confucius". This political office is not only hereditary, but also had the same ranking and remuneration as that of a cabinet minister in the government of the Republic of China. In 2008, with permission from the Kong family, the political office became an unpaid one which is purely ceremonial in nature. It is currently held by Kung Tsui-chang, a 79th-generation descendant of Confucius.

There are also similar political offices for the descendants of the other notable members of the Confucian school (the Four Sages), such as "Ceremonial Official to Mencius", "Ceremonial Official to Zengzi", and "Ceremonial Official to Yan Hui". In the reformation of the law in 2009, "Ceremonial Official to Mencius" and "Ceremonial Official to Zengzi" would become unpaid honorable titles as well once the incumbent officials decease.

The tombs of the Dukes Yansheng of the Ming and Qing dynasties are located at the Cemetery of Confucius in Qufu, Shandong.孔林: 墓葬 (Cemetery of Confucius: Burials)

History Kong Qiu (551–479 BC), better known as Confucius, was a teacher, politician and philosopher of the State of Lu in the Spring and Autumn period of ancient China. He was a descendant of the royal family of the Shang dynasty (c. 1558–1046 BC) through the dukes of the State of Song (11th century – 286 BC).

Qin dynasty (221–206 BC) and the Western and Eastern Han dynasties (206 BC – 220 AD) During the reign of Qin Shi Huang (r. 247–210 BC), the First Emperor of the Qin dynasty, Kong Fu (), a ninth-generation descendant of Confucius, was awarded the title "Lord Wentong of Lu" () and the appointment of shaofu ().

In 190 BC, Emperor Gao of the Han dynasty awarded the title "Lord Fengsi" (; "Ceremonial Officer") to Kong Teng (), Kong Fu's younger brother.

During the reign of Emperor Yuan (r. 48–33 BC), Kong Ba (), a 13th-generation descendant of Confucius, was granted the title "Lord Baocheng" (). In addition, the income gained from the 800 taxable households in Kong Ba's fief were used to finance the worshipping of Confucius. Kong Ba also instructed his eldest son, Kong Fu (), to return to their ancestral home to serve as a ceremonial official to their ancestor.

The title "Marquis Yinshaojia" () was conferred on Kong Ji (), a 14th-generation di descendant of Confucius, by Emperor Cheng (r. 33–7 BC). The emperor also allowed Kong Ji to perform ritual sacrifices to Cheng Tang, the first king of the Shang dynasty, and granted him the () ceremonial privilege.

During the reign of Emperor Ping (r. 1 BC – 6 AD), granted the title "Marquis Baocheng" () to Kong Jun (), a 16th-generation descendant of Confucius.

Emperor Ming (r. 58–75 AD) awarded Kong Juan (), an 18th-generation descendant of Confucius, the title "Marquis of Bao Village" ().

Emperor An (r. 106–125 AD) gave the title "Marquis of Fengsheng Village" () to Kong Yao (), a 19th-generation descendant of Confucius.

The title of Duke of Song and "Duke Who Continues and Honours the Yin" (殷紹嘉公) were bestowed upon Kong An (孔安 (東漢) by the Eastern Han dynasty because he was part of the Shang dynasty's legacy.《汉书·杨胡朱梅云传》:初,武帝时,始封周后姬嘉为周子南君,至元帝时,尊周子南君为周承休侯,位次诸侯王。使诸大夫博士求殷后,分散为十余姓,郡国往往得其大家,推求子孙,绝不能纪。时,匡衡议,以为“王者存二王后,所以尊其先王而通三统也。其犯诛绝之罪者绝,而更封他亲为始封君,上承其王者之始祖。《春秋》之义,诸侯不能守其社稷者绝。今宋国已不守其统而失国矣,则宜更立殷后为始封君,而上承汤统,非当继宋之绝侯也,宜明得殷后而已。今之故宋,推求其嫡,久远不可得;虽得其嫡,嫡之先已绝,不当得立。《礼记》孔子曰:‘丘,殷人也。’先师所共传,宜以孔子世为汤后。”上以其语不经,遂见寝。 This branch of the Confucius family was a separate branch from the line that held the title of Marquis of Fengsheng village and later Duke Yansheng. This practice was referred to as 二王三恪.

Three Kingdoms period (220–280 AD) through Northern and Southern dynasties era (420–589) During the Three Kingdoms period, the state of Cao Wei (220–265) renamed the title "Marquis Baocheng" () to "Marquis Zongsheng" ().

The Jin (266–420) and Liu Song (420–479) dynasties changed the title to "Marquis of Fengsheng Village" ().

The Northern Wei dynasty (386–535) changed the title to "Marquis Chongsheng" () while the Northern Qi dynasty (550–577) called it "Marquis Gongsheng" (). Under the Northern Zhou dynasty (557–581), the title was promoted from a marquis title to a ducal title, "Duke of Zou" ().

A fief of 100 households and the rank of Marquis who worships the sage was bestowed upon a Confucius descendant, Yan Hui's lineage had 2 of its scions and Confucius's lineage had 4 of its scions who had ranks bestowed on them in Shandong in 495 and a fief of ten households and rank of Grandee who venerates the sage was bestowed on Kong Sheng who was Confucius's scion in the 28th generation in 472 by Emperor Xiaowen of Northern Wei.

Sui (581–618) and Tang (618–907) dynasties In the Sui dynasty, Emperor Wen (r. 581–604) awarded the title "Duke of Zou" () to Confucius's descendants, but Emperor Yang (r. 604–618) downgraded and renamed the title to "Marquis Shaosheng" ().

During the early Tang dynasty, the title was renamed to "Marquis Baosheng" (). In the Kaiyuan era (713–741) of the reign of Emperor Xuanzong, the emperor posthumously honoured Confucius as "Prince Wenxuan" () and promoted the "Marquis Baosheng" title to "Duke Wenxuan" ().

Duke Wenxuan Kong Renyu lived during the Later Tang dynasty.

A line in the Book of Rites had an interpretation written by Kong Yingda. Kong Yingda wrote some interpretations on the Record of Music. was compiled by Kong Yingda. Kong Yingda wrote a new edition of the Shijing. Confucius' scion in the 32nd generation Kong Yingda wrote interpretations of the Confucian 5 Classics called the Wujing zhengyi. A description was written by Kong Yingda on the Di sacrifice. Zhaomu were also mentioned by Kong.

Northern and Southern Song dynasties (960–1279) In 1055, Emperor Renzong, changed the "Duke Wenxuan" title to "Duke Yansheng" () to avoid naming taboo associated with the posthumous names of the earlier emperors. The title "Duke Yansheng" was then awarded to Kong Zongyuan (), a 46th-generation descendant of Confucius. It was later changed to "Duke Fengsheng" () but was quickly restored back to "Duke Yansheng", and has since then been known as "Duke Yansheng".

Confucius' house was built over by the Confucius temple with things like the Apricot Altar remaining from his house where Confucius lectured disciples.

During the wars between the Song dynasty and Jurchen-led Jin dynasty (1115–1234), the Song capital, Kaifeng, was conquered by Jin forces in 1127. Remnants of the Song dynasty retreated south and established the Southern Song dynasty, with Emperor Gaozong (r. 1127–1162) as their ruler. Kong Duanyou (), who then held the Duke Yansheng title, also moved to the south and settled in Quzhou, Zhejiang, where the southern branch of Confucius's descendants was created. Kong Duancao (), Kong Duanyou's brother, remained in Qufu, Shandong, where he called himself the "acting Duke Yansheng". Later on, the Jin dynasty recognised Kong Duancao's legitimacy. This resulted in a north–south split among the descendants of Confucius. Historians regarded the southern branch as the di (legitimate) successor to Confucius's line, while the northern branch is seen as a shu (offshoot) branch.

The Kong family held their office and title for the most continuous and longest time out of all families in China's history. They were granted the title Duke Yansheng by the Song dynasty in 1055 and were symbolically and military important to the Song, Jin and Yuan dynasties in their wars over northern China as they symbolized Confucianism and served as military agents of those dynasties in the northern China region.