Charged as an adult, Hribal faces four counts of attempted homicide and 21 counts of aggravated assault, and was ordered to face a preliminary hearing in seven to 10 days.

Students described a scene of panic, with the school hastily evacuated after a fire alarm was pulled.

"He did it so stealthily that at first no one knew what was happening," freshman Josh Frank said.

"We heard a girl scream bloody murder. Then two seniors were running down the hall and we followed them out of the school."

"I saw Jared right towards the front of the school where the office is with his shirt up, looking into the office screaming 'Help! Help!' with a stab wound on his stomach bleeding down," another student said.

The attacker, described by a classmate as a quiet person who kept to himself, started his rampage about 7:13 am (local time), walking along the hallways to several classrooms at the school in Murrysville, 32 kilometres east of Pittsburgh.

Assistant principal Sam King tackled the boy, who was armed with two straight knives about 20 to 25 cm long, and an armed security officer handcuffed him with help from Mr King, said Murrysville police chief Thomas Seefeld.

I saw Jared right towards the front of the school where the office is with his shirt up, looking into the office screaming 'Help! Help!' with a stab wound on his stomach bleeding down.

Franklin High School student

Twenty-one students and a security officer were stabbed in the incident, said Dan Stevens, a spokesman for Westmoreland County emergency management.

Two other students suffered minor injuries trying to get out of the school, Mr Stevens added. He said the teenage suspect was not counted among the wounded.

The suspect was also being treated for injuries to his hands, Chief Seefeld said. By late afternoon one or two of the victims were "still pretty critical".

Among those praised for heroics during the incident was Nate Scimio, the student who pulled the fire alarm and helped shield classmates, witnesses said.

"There's not enough words to describe how much of a hero he is," classmate Trinity McCool posted on Facebook.

The victims, most of them 14 to 17 years old, were transported to area hospitals, four by medical helicopters. Several had life-threatening injuries, hospital officials said.

Dr Louis Alarcon of the University of Pittsburgh Medical Centre operated on a 17-year-old student and said he had "a large injury to his abdominal wall".

The knife "went through his liver, diaphragm and major blood vessels," he said.

"Fortunately for this young man, the knife missed his heart and his aorta."

While the United States has seen a number of large-scale school shootings in recent years, mass stabbings are less common.

Police and the FBI were searching the suspect's home, situated at the end of a quiet cul-de-sac.

Neighbours said both parents work and the teen has a brother who also attends Franklin Regional High School.

"I don't know him really well, but he's always said 'hi'," said neighbour Lori Renda, 47, who said he played with her own children.