Nikolas Cruz, who killed 17 people when he opened fire at a school in Florida, had an obsession with guns and frequently espoused racist and homophobic views on social media.

The 19-year-old, who committed one of the worst mass shootings in US history, made racist slurs and wrote that he hated "jews, ni**ers, immigrants," in an Instagram group viewed by CNN.

In the group called "Murica great", Cruz told the five other members that he wanted to kill Mexicans, keep black people in chains and slit their throats.

Cruz said he hated black people simply because they were black and that he hated Jews because he thought they wanted destroy the world.

When another member of the group said he hated gay people, Cruz wrote: "Shoot them in the back of head."

Nikolas Cruz
On social media, shooter Nikolas Cruz revealed his obsession with guns and violence. Broward County Sheriff's Office

He described white women who had interracial relationships as "traitors."

The group members shared an endless stream of racist messages, memes and videos with each other.

Cruz legally bought his AR-15 rifle in Florida about a year ago. He frequently boasted about his gun to other members of the group.

He also bought body armour, sharing pictures of his purchase on the group. He asked the others whether it was legal to wear the armour to school. When someone asked him why he wanted to, he replied: "School shooters."

At another point in the conversation, Cruz wrote: "I think I am going to kill people." When he was told by the others not to make such comments, he said he was just joking.

The FBI was reportedly alerted about a person named Nikolas Cruz after he commented on a YouTube video that he was "going to be a professional school shooter."