The 29-year-old man attacked three school children and a parent with a vegetable knife around 11:30 a.m. [03:30 GMT], the Shanghai police said in a statement.
The victims have been taken to a hospital, two school kids died while a third and a parent are not in a life-threatening condition, the police noted.
Earlier in April, a 28-year-old man who despised children because he had been bullied at school stabbed to death seven Chinese middle school students who were on their way from classes in the northwestern province of Shaanxi.
Violent crimes are often blamed on people with mental illness or who have personal grievances.
Knives are most commonly used in such attacks because gun control is extremely severe in China.