Nikolas Cruz, who killed 17 people in one of America's worst school shootings, left a trail of chilling anti-Semitic, racist, homophobic, and homicidal messages on social media in the months before he struck.

One of the classrooms where he killed pupils was engaged in a Holocaust history lesson, according to a pupil who survived, although it was unclear if the gunman himself would have known that.

Cruz's horrific comments were posted to a private group containing half a dozen people on the Instagram messaging service, which is owned by Facebook.

The name of the group was "Murica great" accompanied by an American flag and eagle, and Cruz began posting to it in August last year. It was discovered by CNN.