Homer stops by the Kwik-E-Mart on the way home from work, and witnesses a robbery committed by a masked clown, resembling Krusty. He identifies the clown as Krusty to the police, and Krusty is arrested, upsetting Bart, who considers him to be his idol. During his trial the next day, Krusty is revealed to be illiterate. After being called out to the stand, Homer points out Krusty as the robber, and he is convicted and sentenced to jail. The community then gathers up in a public burning as they burn up all of Krusty's merchandise. Krusty's sidekick Sideshow Bob becomes the new host of his show and making it a more educational program, while retaining the popular Itchy and Scratchy cartoons. Still refusing to accept that his hero could have committed the crime, Bart enlists the help of a reluctant Lisa and they set out to prove Krusty's innocence.
At the scene of the crime, Lisa deduces Krusty could not have been the robber because the robber used the microwave not suitable for those with a pacemaker, and reading a magazine at the magazine rack (which Krusty is illiterate). She accepts Bart's theory that he may have been framed. She asks Bart if there was anyone who had motives to see Krusty gone and he suggests they ask Sideshow Bob because he may identify any known enemies. Bart and Lisa go to Sideshow Bob for his help in finding out if Krusty had any known enemies who wanted him gone, but are given tickets to his show. At the live broadcast, Bart is invited up on stage with Bob, where he points out the facts regarding the microwave and magazine, which Bob dismisses. When Bob says he has "a lot of big shoes to fill", Bart remembers how Homer stepped on the robber's shoes that made him scream in pain. When he watched Krusty head to trial, he was wearing normal shoes much too small to hold feet as large as the robber's. Bart knew that despite wearing clown shoes all the time, Krusty never would have felt Homer stepping on them due to his small feet. It was then he realized that Sideshow Bob is the real robber, since he had the most to gain in Krusty's downfall and has large feet. Bart proves his evidence by hitting Bob's feet with a comedy mallet on live television. The police, having watched the show, realized they wrongfully put Krusty in jail for a crime he did not commit and head down the studio to arrest Sideshow Bob.
Arrested and exposed, Bob confesses that the reason he framed Krusty was out of frustration for constantly being on the receiving end of the clown's humiliating gags. He gives a grudging kudos to the Simpson kids and vows revenge on Bart, setting up a recurring plotline in future episodes. Being carted of to jail, Bob warns criminals not to underestimate children in spite of their innocent looks, because they were smart to foil him and can do the same to them. The charges against Krusty are dropped and he regains the trust of the community. Homer then apologizes to Krusty for incriminating him in court, and Krusty thanks Bart for standing up for the truth and sticking to his convictions, and a picture is taken of the two shaking hands (which Bart later hangs in his bedroom, refilled with Krusty decor).