Han Xiangzi, courtesy nameQingfu or Beizhu, is a Chinese mythological figure and one of the Eight Immortals in the Taoist pantheon. He studied Taoist magical arts under the tutelage of Lü Dongbin, another of the Eight Immortals. Han Xiangzi is often depicted carrying a dizi (Chinese flute), so he is also regarded as the patron deity of flutists. He is also believed to be the composer of the Taoist musical piece Tian Hua Yin (天花引).
It is not known if Han Xiangzi existed historically. However, he is believed to be Han Xiang, a grandnephew of Han Yu, a prominent politician, poet and Confucian scholar who lived in the Tang dynasty. There are at least three different accounts about Han Xiang and Han Yu's grandnephew.
Han Yu once dedicated three poems to his grandnephew, Han Xiang, whose courtesy name was "Qingfu". The three poems are Zuo Qian Zhi Languan Shi Zhisun Xiang (左遷至藍關示侄孫湘), and the two-part poem Su Zeng Jiang Kou Shi Zhisun Xiang (宿曾江口示侄孫湘). In 819, during the reign of Emperor Xianzong of Tang, the emperor arranged a grand ceremony for an alleged Buddhist relic to be escorted to the imperial palace in Chang'an and encouraged the people to worship the relic and donate to Buddhist monasteries. Han Yu wrote a memorial to Emperor Xianzong to advise him against doing so, and drew on the example of Emperor Wu of Liang and Hou Jing to caution the emperor. Emperor Xianzong was furious and wanted to execute Han Yu, but eventually pardoned him, demoted him, and sent him out of Chang'an to serve as the Prefect of Chao Prefecture (潮州; present-day Chaozhou, Guangdong). Along the way, Han Yu passed by Lan Pass (藍關; in present-day Lantian County, Xi'an, Shaanxi), where Han Xiang came to join him on his journey. Han Yu wrote the poem Zuo Qian Zhi Languan Shi Zhisun Xiang and dedicated it to Han Xiang.
The historical text New Book of Tang mentioned that Han Yu had a grandnephew, Han Xiang, whose courtesy name was "Beizhu". Han Xiang served as a da li cheng (大理丞), an official in the Ministry of Justice, under the Tang government.
In the miscellany Miscellaneous Morsels from Youyang, Han Yu had an unnamed grandnephew who lived in the Huai River region. He instructed his grandnephew to study Confucian classics in a school, but his grandnephew showed no interest in his studies and bullied his classmates. Han Yu then arranged for his grandnephew to study in a Buddhist school, but the abbot complained that he was defiant and reckless. Han Yu then brought his grandnephew home and scolded him for not spending his time productively. However, his grandnephew claimed that he had the special ability to change the colour of peony flowers, and demonstrated it in front of him. Han Yu was greatly surprised. His grandnephew then returned to the Huai River region and led the rest of his life as a simple commoner.