Alex Cormier is rushing to her job as a judge, while her daughter Josie, a “pretty, popular, straight-A student” drinks coffee. Yet beneath this exterior, Josie is miserable, and keeps a bag of Ambien taped to her dresser to use in case she decides to kill herself. Her boyfriend, Matt, arrives to take her to school, and for a moment Josie forgets all her troubles. Later that day at school, a student named Zoe Patterson leaves Mr. McCabe’s math class early in order to go to an orthodontist appointment. While she is waiting on the school steps, she hears an explosion. Patrick Duharme, the town of Sterling’s only police detective, gets reports of a shooter at Sterling High School. Running through the school, Patrick finds Josie lying next to Matt’s dead body and carries her out.
Seventeen years earlier, Alex and Lacy Houghton meet in a prenatal class that Lacy, a midwife, is teaching. Alex is 24 and considered terminating her pregnancy, but now seems to want to have the baby. Alex is a public defender; the father of her child is her married law professor, Logan Rourke. Alex gives birth with Lacy as her midwife.
Hours after the shooting takes place, Lacy arrives at Sterling High to check on her son, Peter, only to hear someone say that he is the shooter. Peter is in custody, having been arrested by Patrick. Ten people have been killed in the shooting, nine students and one teacher, Mr. McCabe. Josie is in the hospital and can’t remember anything; she believes she was in a car accident. Peter’s father, Lewis, contacts Jordan McAfee, a lawyer who is initially hesitant about representing Peter, but then agrees to do so.
The novel jumps back twelve years. Peter is so excited for his first day of kindergarten that he can’t sleep. Lacy makes her elder son Joey promise that he will look after Peter, but as soon as they get on the bus Joey abandons him. Almost immediately, another kid makes fun of Peter’s lunchbox and throws it out of the bus window, but Josie says she will share hers with him. Peter continues to be bullied; although he initially hides this from Lacy, she soon finds out the truth. Josie gets in trouble for beating up Drew Girard in defense of Peter. One day, Alex comes to pick Josie up from a playdate at Peter’s house only to find the two of them playing with Lewis’ gun collection. Alex is horrified, and this causes a fight between her and Lacy.
The day after the shooting, Josie comes home from the hospital. The police remove a trove of suspicious items from Peter’s room. Josie goes to Matt’s funeral service, where she is overcome by an urge to approach his casket, only to break down in front of everyone and feel mortified. Lacy goes to visit Peter in prison. Patrick watches the surveillance footage from the day of the shooting, and is disturbed to see Peter sit down to eat a bowl of Rice Krispies in the middle of his murder spree.
The novel flashes back again. On Peter’s first day of middle school, Drew pushes Peter and calls him a “retard.” The September 11 attacks on the World Trade Center take place, and Alex and Lacy pick up their kids from school, both reeling. Peter befriends another awkward, nerdy kid forced to play soccer by his parents, Derek Markowitz, and the two quickly form a bond. Meanwhile, in social studies Josie is partnered up with one of the popular girls, Courtney Ignatio. Although Josie is initially horrified by this, she and Courtney end up becoming friends. Peter and Lewis go hunting together; Joey stays at home because he can’t stand the sight of blood. As Josie becomes closer with the popular kids, Peter accuses her of being fake.
Back in the present, Principal McAllistar notes that, because Sterling High is still the scene of an ongoing criminal investigation, school will resume in another location. Jordan’s wife, Selena, who also works as his investigator, questions Lacy about Peter. Meanwhile, Patrick speaks to Natalie Zlenko, the president of Sterling High GLAD, wondering if Peter’s attack might have been motivated either by homophobia and/or Peter’s concerns about being gay himself. Natalie says Peter came to one GLAD meeting and never returned.
Jordan goes to the jail to see Peter, who reveals that Joey was killed by a drunk driver. Peter states that—because Joey tormented him and set unrealistically high expectations for his own behavior—Peter is glad his brother is dead. Jordan decides to argue that Peter was suffering from battered woman syndrome, a psychological state caused by ongoing exposure to abuse, which can lead the victim to commit acts of violence against their abuser. Meanwhile, Patrick examines a computer game Peter designed that is set in a school and whose main objective is killing jocks in a violent manner. The game is called Hide-n-Shriek. One of Peter’s victims was a special-needs student called Kaitlin Harvey; her mother, Yvette, kills herself while pretending to examine a gun at a gun sore.
One year before the shooting, Josie happens across an article about her father, whom she has never met, in the Boston Globe. The article states that he is now dean of students at Harvard Law School and is running for district attorney. Peter and Josie end up both working at the town copy shop, QuikCopy. Josie has now assimilated into the popular crowd to the point that Peter doesn’t recognize her. At work, Peter shows off his computer hacking skills, and Josie asks him to find Logan’s address for her. Shortly after, Peter gives a presentation about popularity in math class in which he cites Josie as a “bridge,” someone who can easily move between social groups. Josie is humiliated and tells Peter never to speak to her again. Shortly after, Peter sets fire to a dumpster at work in an effort to force Josie to “rescue” him from the flames. She does, but reports him to their boss, Mr. Cargrew, who promptly fires Peter.
Around this time, Matt drives Josie to Logan’s house. However, Logan doesn’t want to see her and gives her $300 to stay away from him. Peter goes to a gay bar in order to figure out if he’s truly gay as his bullies claim. An older man named Kurt becomes sexually aggressive toward him and Mr. McCabe rescues him, admitting to Peter that he is gay (although he remains closeted at school). Back at school, Josie and Peter get stuck in an elevator together and play games to pass the time. During a game of “Truth or Dare,” Josie admits that the reason why she is on crutches is because Matt hit her, causing her to break her leg.
A month after the shooting, Patrick goes to visit Ed McCabe’s partner Philip, who tells Patrick that Ed did not think Peter was gay. A journalist named Elena Battista writes to Peter in jail, claiming to be a college student and a survivor of bullying. Jordan goes to see Dr. King Wah, a forensic psychiatrist and expert on battered woman syndrome, to ask him to evaluate Peter for the trial. Elena comes to interview Peter for a paper she is writing about bullying, and Peter is excited by how attractive she is. However, it is soon revealed that Elena is actually a journalist who only pretended to be writing a paper for college, and was actually writing a tabloid article about Peter entitled “Inside the Mind of a Killer.” Jordan furiously reprimands Peter for communicating with someone on the outside without notifying him.
Alex and Patrick run into each other at a Chinese restaurant and strike up a conversation. When Patrick mistakes Alex’s mentor Whit Hobart for her date, he feels deeply disappointed even though he knows it should be none of this business. Alex recuses herself from serving as the judge for the shooting case due to her personal connection to it. In jail, Peter beats up his new cellmate, who appears to be cognitively impaired. A romance begins between Alex and Patrick.
The month before the shooting, Matt tries to persuade Josie to have sex without a condom. Peter writes Josie an email confessing his love for her; Courtney reads it while Josie is in the shower and sends it out to the whole school. Josie is terrified by the realization that she is pregnant. At school, she is humiliated by the revelation that everyone has read the email Peter sent her. Courtney tricks Peter into believing Josie likes him back. The truth is then brutally revealed, and Matt pulls down Peter’s pants in front of the whole cafeteria. Soon after, Peter steals two semiautomatic guns from his neighbor, a retired cop named Mr. Weatherall. Josie has a miscarriage, potentially as a result of her own efforts to terminate the pregnancy using natural remedies.
Five months after the shooting, the jury for Peter’s trial is selected. Alex and Patrick’s relationship is going strong, and although Alex is still trying to keep it secret from Josie, Josie reveals that she knows what’s happening. The trial begins, and in his opening speech Jordan argues that Peter was suffering from PTSD when he committed the shooting.
Various people provide witness testimony; Jordan intensively interrogates Drew about his history of bullying Peter. On the stand, Derek explains that—even though he and Peter designed and played Hide-n-Shriek together—he was shocked and horrified that Peter actually committed a mass shooting in real life.
On the morning of the shooting, Peter gets on the computer to see if any users have uploaded comments after he shared Hide-n-Shriek in a forum, but his computer freezes on the email he sent Josie, and he is overwhelmed with shame, panic, and horror.
Back at the trial, a forensic psychiatrist and expert in school shootings named Dr. Curstis Uppergate concludes that he does not think Peter was mentally ill when he committed the attack; after, King Wah gives the opposite view, arguing that Peter suffered from battered woman syndrome and PTSD, and was dissociating at the time of the shooting. Lacy gives her testimony, followed by Peter himself, who deviates from what he planned to say and comes off in a decidedly unsympathetic manner.
Horrified at the bad turn the trial has taken, Jordan decides to call Josie as a witness as a last-ditch attempt to elicit sympathy for Peter. On the witness stand, Josie confesses that after fleeing to the locker room with Matt, they were found by Peter, who accidentally dropped a gun that Josie picked up. At first she pointed it at Peter, but ended up shooting Matt in the stomach. Peter then shot Matt in the head.
Following Josie’s confession, the courtroom erupts in chaos. Peter is ultimately convicted of eight first-degree murders and two second-degree murders. He is sentenced to life in prison, but kills himself almost immediately after the trial by stuffing a sock down his throat. Josie is charged as an accessory to second-degree murder and is sentenced to five years in prison. At the end of the novel, a year after the shooting, Patrick and Alex walk through Sterling High, which now has a memorial to the murdered students. Alex is pregnant.