The attacker fled after a Chinese colleague of the victim intervened and the man was captured by police shortly afterward, the French Consulate in Shanghai said in a notice on its website.
"Given the situation, the French embassy in China calls on members of the French community to exercise the utmost vigilance," the statement said.
The attacker was a 27-year-old Shanghainese man surnamed Mao, the police department of Shanghai's Xuhui district issued a statement on its microblog. It said the French citizen had been lightly injured on his neck and that the case was under investigation, but gave no suspected motive.
The killing has been extensively reported on in Chinese media and the foreign ministry on Tuesday summoned a representative of the French embassy in Beijing to express its concern over the case.
It has also called for Chinese nationals in France to express their wishes and demands "in a reasonable way.