A native of Jiangsu, Zhang obtained a jinshi (successful candidate) position in the imperial examination in 1709 and was employed in literary and examination work, rising in 1733 to be the Secretary of the Ministry of Justice. Two years later, he narrowly escaped execution for his failure to arrange the management of the aboriginal territories in Guizhou. He was again employed on literary work, and was joint compiler of the Lülü Zhengyi (律呂正義) and its sequel Houbian (後編) under the same name, the two standard treatises on music. His poems were much admired by the Yongzheng Emperor, who was especially struck with some verses written with his left hand after a fall from his horse had disabled his right arm. He died of grief for the loss of his father. In his Retrospect (懷舊詩, 1779) the Qianlong Emperor numbered him among his Five Men of Letters (五詞臣), the others being Qian Chenqun, Liang Shicheng, Shen Deqian, and Wang Yudun. He was given the posthumous nameWenmin (文敏).