Family
Cao was born to a Han Chinese clan that was forced into slavery (as bondservants) to the Manchu royalty in the late 1610s, his ancestors distinguished themselves through military service in the Plain White Branch (正白旗) of the Eight Banners and subsequently held posts as officials.

During the Kangxi Emperor's reign, the clan's prestige and power reached its height. Cao's grandfather, Cao Yin (曹寅), was a childhood playmate to Kangxi while Cao Yin's mother, Lady Sun (孫氏), was Kangxi's wet nurse. Two years after his ascension, Kangxi appointed Cao's great-grandfather, Cao Xi (曹玺), as the Commissioner of Imperial Textiles (织造) in Jiangning, and the family relocated there.

When Cao Xi died in 1684, Cao Yin, as Kangxi's personal confidante, took over the post. Cao Yin was one of the era's most prominent men of letters and a keen book collector. By the early 18th century, the Cao clan had become so rich and influential as to be able to play host four times to the Kangxi Emperor in his six separate itinerant trips south to the Nanjing region.

When Cao Yin died in 1712, Kangxi, still in power, passed the office over to Cao Yin's only son, Cao Yong (曹顒). Cao Yong died in 1715. Kangxi then allowed the family to adopt a paternal nephew, Cao Fu (曹頫), as Cao Yin's posthumous son to continue in that position. Hence the clan held the office of Imperial Textile Commissioner at Jiangning for three generations.

The family's fortunes lasted until Kangxi's death and the ascension of the Yongzheng Emperor to the throne. Yongzheng severely attacked the family and later confiscated their properties, while Cao Fu was thrown in jail. This was for their mismanagements of funds. Many believe this purge was politically motivated. When Cao Fu was released a year later, the family, completely impoverished, was forced to relocate to Beijing. Cao Xueqin, still a young child then, lived in poverty with his family.