Hermione Granger is a nerd. And an activist. And unabashedly bossy. And in the “Harry Potter” books’ extended metaphor about racism and prejudice, she is a member of the looked-down-upon “mudblood” class.

She’s already fairly radical for a children’s book character, so it’s not that much of a logical leap to picture her as black. Which, for years, fans online have been adeptly doing.

There are Tumblrs and lengthy blog posts dedicated to “racebent” Hermione, extended discussion threads on Reddit about whether author J.K. Rowling ever specified her race (the consensus: not really), and pages and pages of illustrations of what a Hermione of color might look like.

Next summer, fans will see that version on stage: In a new Harry Potter play marketed by Rowling as the series’ eighth installment, Hermione will be played by Noma Dumezweni, a British actress born to South African parents fleeing apartheid.

Needless to say, the corners of the Internet that have been imagining Hermione as black for two decades were very pleased.

The casting also got a stamp of approval from Rowling, who wrote the script for “Harry Potter and the Cursed Child.”

https://twitter.com/jk_rowling/status/678888094339366914

Dumezweni also has deep London theater bona fides: she won a Laurence Olivier Award in 2006 for her performance in Lorraine Hansberry’s “A Raisin in the Sun” and has acted with the Royal Shakespeare Company. She’s also been on Doctor Who — likely the best way to win over any British audience.

In the two-part “Harry Potter and the Cursed Child,” which chronicles an aging Harry Potter’s life as a harried parent and Ministry of Magic employee, she’ll perform alongside British actors Jamie Parker as Harry and Paul Thornley as Ron. Parker is best known for playing the role of Scripps in “The History Boys.” Thornley was in the play “London Road,” as well as its film adaptation.

To fans of “racebent” Hermione, the casting of Dumezweni makes sense. Her appearance is only ever described in terms of her bushy hair and large teeth. And she is a member of a despised minority in the wizarding world — a girl born to non-magic parents, subjected to slurs about her “blood” and upbringing that might be familiar to young black readers.

“In middle school, when I was confronting that there were people out there who’d call me [the n-word], I thought back to Hermione being called “mudblood” and harassed by teacher and students alike,” BuzzFeed film and TV writer Alanna Bennet wrote early this year.

“Painting Hermione as a woman of color,” Bennet continued, “[is] an act of reclaiming her allegory at its roots.”