A 16-year-old boy made a potential bomb filled with shrapnel and told pupils he was going to "go on a rampage" and "kill many people", a court has heard.
The teenager from Bradford, who cannot be named because of his age, is accused of making a CO2 bomb in June 2018.
Leeds Crown Court heard the boy had also told fellow students in 2017 he was going to carry out a school shooting and had praised Adolf Hitler.
He denies five terrorism-related offences.
Jurors heard the boy had a copy of "Anarchist's Corner" - a document containing bomb-making instructions - and had developed an interest in extremist far-right ideology.
Prosecutor Paul Greaney QC said the boy had built a device that "would have been a viable CO2 bomb" with the "simple addition of gunpowder".
"Furthermore, he had loaded that device with shrapnel, such as is commonly used by bomb-makers to cause maximum harm and death to civilians," he added.
Jurors were told the boy had carried out "disturbing, indeed menacing" searches on the internet about murder, torture and mutilation.
"He spoke to fellow pupils of carrying out a school shooting and praised Adolf Hitler, stating 'gas the Jews'," Mr Greaney said.
Police were first alerted to the boy when he was aged 13 and he was referred to the government's counter-terrorism strategy Prevent a year later, the court heard.
The following year Prevent received information he had told fellow pupils he was going to "go on a rampage, aiming to kill many people and then be shot by the police or kill himself", jurors were told.
During a raid at the boy's home, officers found two carbon dioxide canisters joined together and an assortment of nails, tacks and panel pins, Mr Greaney said.
The boy denies one count of making an explosive substance with intent, one count of making an explosive substance and three counts of possession of a document likely to be useful to a person committing or preparing an act of terrorism.
The trial continues.