A native of Suzhou, he became an official during the reign of Emperor Xuanzong of Tang. Zhang was known as one of the Eight Immortals of the Wine Cup. Legend has it that whenever he was drunk, he would use his hair as brush to perform his art, and upon his waking up, he would be amazed by the quality of those works but failed to produce them again in his sober state.
Though more well known for his explosive cursive script, he excelled in the regular script. There is an anecdote that says he grasped the essence of cursive writing by observing some porters fight for their way with the guard of honor of some princess, and by watching the solo performance of a famous sword-dancer named Lady Gongsun (公孫大娘). He was known as 草聖 (the Divine Grassist) for his great skill in the grass script.
Under the excitement of art (and wine), he became oblivious of social expectations, and would often fling off his cap in the presence of princes and nobles. Hence he came to be known as 張顛 (Zhang the Madman). He is often paired with the younger Huaisu as the two greatest cursive calligraphers of the Tang Dynasty. The duo is affectionately referred to as "the crazy Zhang and the drunk Su" (顛張醉素).
One of Zhang Xu's poems was included in the poetry anthology Three Hundred Tang Poems.