Robb was born in Denver, Colorado, the only child of Janet, an interior designer, and David Robb, an architect. She was named after her maternal great-grandmother, Anna Sophie, and her paternal grandmother, Anna Marie. She is of Danish, English, Irish, Scottish, and Swedish descent. She grew up in a Christian home and was home-schooled. She competed in dance and gymnastics for four and a half years, but quit in order to focus on acting. In 2009, the Arapahoe Herald reported that she was attending Arapahoe High School in Centennial, Colorado.
After appearing in a commercial for McDonald's, Robb had a small role in the episode "Number One Fan" of the television series Drake & Josh. Her first major role was as the title character in the television special Samantha: An American Girl Holiday. She wore a long brown wig for the part.
Robb's two big-screen appearances in 2005 were both adaptations of popular children's books. She starred as Opal in Because of Winn-Dixie and as the competitive and rude Violet Beauregarde in Tim Burton's remake of Charlie and the Chocolate Factory. The latter was a major box office success worldwide, and helped escalate Robb's popularity among pre-teen audiences.
In 2005, Robb was the face of Trad Clothing, helping to design and model a fashion line for girls. In 2006, she had a guest role on the cartoon show Danny Phantom as the voice of Danielle "Dani" Fenton. Robb played Leslie Burke in Bridge to Terabithia, which opened in U.S. theaters on February 16, 2007. She recorded a song for the soundtrack titled "Keep Your Mind Wide Open", and the accompanying video received rotation on the Disney Channel. The song peaked at number ninety on the Billboard Hot 100 during the week of March 1, giving Robb her first charting single. Robb was a fan of the book before being cast in the role, saying that it "touched me in a way I hadn't been touched by a book before".
Robb went on to appear in The Reaping, Have Dreams, Will Travel, Jumper, and Spy School. Despite negative reviews of the film overall, Robb's performance in Sleepwalking garnered praise. Time film critic Richard Schickel said: "There is a wonderful range to Robb's work...this is extraordinarily mature acting from someone this young and she wins our sympathy without once begging for it." In 2008, she recorded the voice of Mary Magdalene in The Word of Promise: Next Generation – New Testament: Dramatized Audio Bible. She also starred in Race to Witch Mountain (2009). In 2010, she appeared in The Space Between. She then starred in Soul Surfer, playing Bethany Hamilton, who continued to surf after losing her arm in a shark attack.
In May 2011, Robb was announced to star as Wendy in a new and dark take on the classic story about Peter Pan, tentatively titled Pan. As of 2014, the film has yet to go into production. It was reported on February 3, 2012, that Robb had landed a role in Life at These Speeds. Later that month, Robb was cast as Carrie Bradshaw in The CW's Sex and the City prequel, The Carrie Diaries, and appeared in the summer comedy The Way Way Back.
In May 2012, Robb announced that she was admitted to Stanford University, though she was deferring acceptance due to filming commitments. She will begin attending Stanford in the fall of 2014.