Linghu Defen (Chinese: 令狐德棻; pinyin: Línghú Défēn) (582–666), formally Duke Xian of Pengyang (彭陽憲公), was an official of the Chinese dynasties Sui Dynasty and Tang Dynasty. During Tang, he was a major proponent for the compilation of the histories of Sui and its predecessor Northern Zhou and was eventually put in charge of compiling Northern Zhou's official history Book of Zhou, which was completed in 636.
Linghu Defen was born in 582, during the reign of Emperor Wen of Sui. His ancestors had been from a prominent clan of Dunhuang, but had later relocated to Yi Province (宜州, roughly modern Tongchuan, Shaanxi). His father Linghu Xi (令狐熙) served as an official during Emperor Wen's reign but died in anger after being imprisoned due to false accusations of corruption. Late in the reign of Emperor Wen's son Emperor Yang, Linghu Defen was made the magistrate of Yaocheng County (藥城, in modern Bozhou, Anhui), but as by that time the Sui realm was had been thrown into a state of confusion due to agrarian rebellions, Linghu never took office. In 617, after the general Li Yuan the Duke of Tang rose in rebellion against Emperor Yang's rule, Li Yuan's cousin Li Shentong (李神通) rose as well and made Linghu a member of his staff. In late 617, after Li Yuan captured the capital Chang'an and declared Emperor Yang's grandson Yang You the Prince of Dai emperor (as Emperor Gong), retaining power as regent, he invited Linghu to serve as a secretary on his staff.
In 618, after Li Yuan received news that Emperor Yang had been killed in a coup at Jiangdu (江都, in modern Yangzhou, Jiangsu), he had Emperor Gong yield the throne to him, establishing Tang Dynasty as its Emperor Gaozu. He made Linghu Defen an imperial attendant. In 622, Emperor Gaozu made Linghu Mishu Cheng (秘書丞), the secretary general of the Palace Library, and had him participate on the compilation of the Yiwen Leiju, with the chancellor Chen Shuda.