"Treehouse of Horror XXXI" is the fourth episode of the thirty-second season of the American animated television series The Simpsons, and the 688th episode overall as well as the thirty-first "Treehouse of Horror" episode. It aired in the United States on Fox on November 1, 2020. The episode was directed by Steven Dean Moore, and written by Julia Prescott.
 The episode is made up of four segments: "2020 Election," "Toy Gory" (a parody of the Toy Story franchise), "Into the Homerverse" (a parody of Spider-Man: Into the Spider-Verse), and "Be Nine, Rewind" (a parody of time loop stories, whose title parodies Be Kind, Rewind). Ben Mankiewicz guest-stars in the episode as himself. It also received generally positive reviews, and was watched live in the United States by 4.93 million viewers.
 On Election Day 2020, Marge calls Homer and tells him to get to Springfield Elementary to vote. At the school, Homer quickly decides everyone he wants to vote for, except for who he wants to be President. Lisa enters the booth and tries to get Homer to remember everything bad about the previous four years, but Homer remembers nothing. After reading fifty things that Donald Trump did as president, Homer finally decides who to vote for. However, it turns out Homer just dreamed of voting. On inauguration day, Springfield is in chaos. Then, the Four Horsemen of the Apocalypse fly in the sky holding flags, one with the episode's title.
 In a parody of Toy Story, before donating his toys to charity, Bart decides to torture them, not realizing that they have feelings. Later, Marge gives him a Radioactive Man toy which Bart puts in a microwave, causing it to melt. The rest of the toys decide to seek revenge against Bart, so they kill him and turn his corpse into a toy, greatly distressing his family. The toys then proceed to play with Bart's disemboweled corpse, completing their revenge.
 In a parody of Spider-Man: Into the Spider-Verse, Marge calls Homer to tell him to bring home the Halloween candy, but he ate it all. Homer searches the Nuclear Power Plant for candy and finds what he thinks is a vending machine. When he tries to put a quarter in it, it explodes. After waking up, Homer realizes that versions of him from the Multiverse have appeared. The Homers become friends and spend time together around Springfield. Lisa realizes that the explosion opened a hole in the space-time continuum and tells Homer to recreate the explosion to fix it.
 They head to the Nuclear Power Plant to do so, but Mr. Burns stops them. Versions of Burns and Smithers from other dimensions fight the Homers and win. When Burns learns from a Noir version of Smithers that the Burns of his world is his assistant, he gives in and sends the alternate Homers, Burns and Smithers back to their own dimensions. As a side-effect, Homer begins shifting into the forms of his counterparts.
 In a parody of Happy Death Day and Russian Doll, at her ninth birthday party, Lisa keeps dying and restarting the day. She then learns that Nelson is experiencing the same thing, and that they both have to be alive at the same time in order to live. They try to end the loop by seeking help from Comic Book Guy, but none of his ideas work. So they realize the only way to end it is to kill Gil Gunderson, which they manage to do. Lisa returns home to properly celebrate her birthday. At home, everything is back to normal except that Ralph's head is backwards.
 This is the first episode of the series written by Julia Prescott, host of the Round Springfield podcast.  A clip from the episode was shown during The Simpsons panel at Comic-con @ Home. An extended clip was released during an interview with showrunner Al Jean. The segment "Toy Gory", was animated entirely in CGI, which marks the first time the series has used that animation style since "Treehouse of Horror VI" in 1995. Initially, when first animated, the episode did not include the characters wearing masks, however, to reflect on the COVID-19 pandemic, showrunner Al Jean asked director Steven Dean Moore to have every character except Homer wear a mask. Ben Mankiewicz appears in the episode as himself.
 In 2020, Fox released 13 promotional pictures from the episode. The episode was originally scheduled to air on October 18, 2020, however, due to being preempted by game seven of the 2020 National League Championship Series, the episode was rescheduled to air on November 1, 2020. The episode was screened earlier on October 14, 2020, at "Paley Front Row: Simpsons Treehouse of Horror", a panel discussion put on by Decider, Paley Center for Media, and Fox, and in Canada on Citytv on its originally scheduled airdate of October 18, 2020.
 The segment "Toy Gory", is a parody of the 1995 film, Toy Story. "Into the Homerverse" is a parody of the 2018 film, Spider-Man: Into the Spider-Verse. The clip shown at Comic-con @ Home of the segment, showed Homer meeting Homer Barbera, a parody of Yogi Bear, Snagglepuss, Quick Draw McGraw and Hanna-Barbera co-creators William Hanna and Joseph Barbera, and Disney Princess Homer, a parody of Disney Princesses. Upon meeting Homer Barbera, Homer remarks that Homer Barbera sounds like Art Carney, whose character from The Honeymooners, Ed Norton, is reportedly the inspiration for Yogi Bear. "Be Nine, Rewind" is a reference to the 2008 film, Be Kind Rewind, and a parody of the 2017 film Happy Death Day and the 2019 television series Russian Doll. A clip from the episode showing Homer voting in the 2020 United States elections was released on October 12, 2020, and he cannot decide who to vote for in the presidential election. So, Lisa tries to get him to remember everything that had happened in the previous four years, referring to the Presidency of Donald Trump, but Homer only remembers Faye Dunaway announcing the wrong Best Picture winner at Oscars, so fifty things that Donald Trump did during the previous four years that make him unfit to continue being President are just listed on the screen. The segment also included references to Vladimir Putin, Roger Stone, and Kanye West, with Putin being listed as Trump's running mate, Stone being depicted as trying to interfere with people's right to vote, and a vote for West being considered a vote for Trump.
 In the United States, the episode was watched live by 4.93 million viewers.
 Tony Sokol with Den of Geek said, "The Simpsons season 32 has been offering consistently satisfying episodes of straight and subversive humor. 'Treehouse of Horror XXXI' is the best of the season so far, but the Treehouses are always season highlights, and more reliably than Christmas episodes. No character is safe on Halloween. You can kill Gil as many times as you like. The Simpsons always packs a devilishly delicious trick or treat bag, with nothing so frightening as razor-blade-concealing apples, or anything else remotely nutritious. The opening segment is a political thriller, but the segments themselves are classic comedy." He also gave the episode four and a half out of five stars.
 Jesse Bereta of Bubbleblabber gave the episode a 9.5 out of 10. He thought the episode was one of the more unique Treehouse of Horror episodes in years. He highlighted the 3D animation segment and the sight of Lisa repeatedly dying.