The narrator's friend William Legrand is a poor scion of a formerly wealthy family who leaves New Orleans and travels to Sullivan's Island, near Charleston, South Carolina. The small island is marsh-like and filled with myrtle shrubs, and on the western end of the island lie some small buildings for summer residents. Legrand builds himself a hut within a myrtle thicket on the eastern end. The narrator meets and befriends Legrand here, and he is fascinated by Legrand's intelligence, mood swings, and misanthropy. Legrand enjoys fishing and exploring, and he is always accompanied by his black servant Jupiter, who had been freed by their family but who insists on following and protecting Legrand.
On a chilly October day, the narrator visits his friend for the first time in several weeks and, finding the inhabitants absent, lets himself in with the hidden key. They arrive after dark, and Legrand excitedly describes a new species of bug that he found and lent to Lieutenant G. for the night. The bug is golden with three black spots forming a triangle, and Jupiter insists that the bug's weight suggests that the bug is entirely made of gold. Legrand dismisses the comment and makes a rough sketch of the bug. After the narrator takes a moment to pet Legrand's Newfoundland dog, he says that if the sketch is accurate, then the bug looks exactly like a skull, and he asks where the antennae are. Legrand insists that he drew the antennae very clearly, but when he again views the paper, he grows first red and then pale before locking the paper inside a wallet, which he locks in his writing desk. For the rest of the night, Legrand appears preoccupied, and the narrator decides to leave.
After a month, the narrator receives a visit from the distraught Jupiter, who tells him that Legrand is acting peculiar. Legrand seems nervous and sick, and he keeps writing things on a slate, and one morning he left before Jupiter woke up for the entire day. Jupiter wanted to give Legrand a beating for his nerve but decided to withhold his blows because of Legrand's ill appearance. The servant suspects that Legrand's behavior has something to do with the gold bug, since he knows that the bug bit Legrand. Jupiter wrapped the bug in paper and stuffed up the insect's mouth, but since then, Legrand has been speaking of gold in his sleep. Jupiter gives the narrator a note from Legrand, which asks the narrator to come immediately to his hut. Worried, the narrator agrees to accompany Jupiter to the island.
When they reach the wharf, Jupiter shows the narrator the scythe and three spades that Legrand mysteriously requested that Jupiter buy. By three in the afternoon, they have sailed to the hut, and the highly-strung Legrand tells the narrator that he took the bug back from Lieutenant G. the following morning and that he has kept the bug for himself, since Jupiter was right in that it is made of gold and since he suspects that the gold will allow him to restore his fortunes. Jupiter refuses to bring him the scarab, so Legrand fetches it himself and tells the narrator that he wants the narrator's help, ignoring his friend's suggestion that he might be sick. He convinces the narrator to accompany them on an expedition to the hills after promising that he will see a doctor afterward.
At four o'clock, the three men and the dog head out, equipped with the scythe, spades, lanterns, and bug, and by nightfall they reach a dreary area of hills. They use the scythe to cut away the brambles, and they reach a tall tulip tree. Upon Legrand's prompting, Jupiter agrees to climb the tree with the beetle, despite his fear of the bug. He follows Legrand's directions upward to the seventh limb, where his announcement that the limb is weakened by rot distresses Legrand, causing the narrator to make an unsuccessful attempt to coax Legrand back to the hut. However, Jupiter climbs to the end of the limb without incident and finds a skull with a nail fastening it to the tree. Legrand has him drop the beetle through the skull's left eye after the scythe clears a space beneath the insect on the ground. Legrand marks the spot of the bug's landing and clears a circle between the peg and another point fifty feet in the opposite direction from the tree. With the spades, they begin to dig.
Knowing that he will be unable to convince Jupiter to disobey Legrand and drag him back to his bed, the narrator resigns himself to digging, concluding that he will have to wait to disprove Legrand's bizarre idea of finding a treasure. After two hours of digging, during which they end the dog's barking by tying up its mouth, they dig a five-foot hole but find nothing. They extend the circle and dig to seven feet, and the disappointed Legrand begins to lead the three home before he realizes that Jupiter must have mixed up his right and left. Legrand adjusts the digging markers, and they resume their labors while the narrator becomes more interested in their digging. The agitated dog digs up two skeletons, a Spanish knife, and some loose coins, and the narrator trips over a ring buried in the dirt. They increase their speed and find a perfectly preserved chest of wood, inside which is a heap of gold and jewels. Jupiter repents for his former distrust of the bug, and they move the treasure back to their hut before dawn.
After taking brief naps, they look through the chest and estimate the treasure to be worth about one and a half million dollars (which has the same purchasing power as about forty-five million dollars in 2008 dollars), although later they find that their initial estimate is very low. After their investigations, Legrand explains how he figured out the location of the treasure. He had been insulted by the narrator's insinuations about his bad drawing skills, but when he looked at the scrap of parchment, he realized that in place of his drawing of a beetle was indeed a skull. He turned over the parchment and saw that his own sketch was on the reverse side of the parchment. Recalling that the parchment had not had a picture prior to his sketching of the beetle, he waited until the narrator left and Jupiter fell asleep to consider the affair.
Legrand recalls that he first found the scrap of parchment after the bug bit him, when Jupiter found the scrap of parchment sticking up from the sand near the remnants of an old shipwreck. Jupiter used the scrap to capture the beetle, and Legrand had accidentally kept the scrap when Lieutenant G. had taken the insect for study at the fort. He connected the wreck with the parchment and skull image, which he recognized as a pirate's emblem. That the scrap was parchment and not paper was important because parchment is more durable but less convenient than paper. Its durability and shape suggested that that it was an important memorandum, and because no one could have altered the parchment without Legrand's knowing, he reasoned that the parchment's image must have been brought to light by the fumes of the fire when the narrator placed it on his lap to pet the dog. Legrand gave the entire parchment the heat treatment and saw the figure of a kid goat, which reminded him of Captain Kidd.
Legrand began to feel very lucky, given the coincidences that had led him thus far. He could not recall hearing of anyone finding an important treasure on the South Carolina coast. He rinsed the parchment and, upon reheating, discovered a message written in code, which he assumed to be in English, since the pun on Kidd's name had been in the language. He counted the frequency of the symbols and used them to solve a simple substitution cipher, which revealed the message to be: "A good glass in the Bishop's hostel in the Devil's seat--forty-one degrees and thirteen minutes--northeast and by north--main branch seventh limb east side--shoot from the left eye of the death's-head--a bee-line from the tree through the shot fifty feet out."
Concluding that "Bishop's hostel" referred to an old family named Bessop that gave their name to a rock called Bessop's Castle, Legrand had an old lady direct him to the rock, where he saw a ledge formation that resembled a seat. He sat in the seat and used a telescope to view forty-one degrees and thirteen minutes above the horizon in the stated direction until he found the image of a skull. He decided that he had to find the tree at that point and drop an object straight down the skull's left eye to find the fifty-foot diameter away from the tree in which he would have to dig. Observing that only someone in the exact angle of the seat could have seen the break in the foliage to find the skull, he returned home and sent for the narrator. He had only insisted on using the bug because he wanted to goad the narrator, who obviously believed him mad. Upon the conclusion of his tale, the narrator asks about the skeletons above the chest, and Legrand speculates that Kidd must have killed the people who help him bury the treasure in order to preserve his secret.
Although it does not at first appear to be so, "The Gold Bug" is akin to a detective story, complete with William Legrand as the hut-dwelling American counterpart to the French C. Auguste Dupin in "The Murders in the Rue Morgue" and "The Purloined Letter" and the narrator as the confused but intelligent sidekick who witnesses the central character's genius. Like Dupin, Legrand is the poor descendant of an old family who enjoys intellectual pursuits and who keeps a mercenary eye for the occasional opportunity to regain some of his wealth. Legrand's explanation of how he used observation and logic to discover the secret of Captain Kidd's treasure bears some similarities to Dupin's method of ratiocination, and they both display a fondness for subtly poking fun at others, such as the Prefect of police in "The Purloined Letter" and the narrator and Jupiter in "The Gold Bug" for their lack of insight. Legrand's explanation at the end also has the flavor of a detective's reveal.
As in "The Premature Burial," the first half of "The Gold Bug" creates what is in hindsight an extremely misleading atmosphere. The narrator does not take Jupiter's constant suggestions that the bug is actually made of gold and that its bite made Legrand sick and possibly mad at face value, but nonetheless Legrand gives no indication that he has refuted Jupiter's ideas until after they find the treasure chest. Before Legrand explains the significance of the skull and says that he was simply playing a practical joke on his friends, the relationship between the gold bug and the image of the skull seems sinister and possibly supernatural. However, Legrand defies expectations and reveals a relatively ordinary explanation, and despite the title of the story, the gold bug is essentially irrelevant to the treasure hunt and turns out to have been nothing more than a coincidence.
The most obvious foreshadowing of the use of the gold bug as a false lead comes at the beginning of the story in the epigraph, which states, "What ho! what ho! this fellow is dancing mad! He hath been bitten by the Tarantula," and is attributed to "All in the Wrong." The quote refers to old stories of people who were bitten by spiders and danced what become known as the tarantella folk dance to cure themselves of the poison. Without the attribution, the quote would refer to Legrand's illness and strange behavior that supposedly results from his bite by the beetle, but the fact that the epigraph comes from a source named "All in the Wrong" hints at the eventual insignificance of the bug's bite. The only bite that has really affected Legrand is the suggestion of a vast treasure to restore his fortunes.
Because he is a black former slave with a stereotyped accent and several obvious gaps in his knowledge, such as the difference between left and right, Jupiter is distinctly a product of the antebellum period in which Poe was writing. At the time, he would have served as a figure of comical relief, whose unintentional puns and misunderstandings such as "Dey aint no tin in him, Massa Will" when Legrand was referring to the bug's antennae would have added a lighthearted element to what is essentially a tale about treasure hunters. Indeed, because Jupiter was freed by the Legrands prior to their fall in their fortunes and because unlike most contemporary black characters, Jupiter has an important, if stereotypical, speaking role, Jupiter is a comparatively progressive character for a member of his race living in the South. Nevertheless, to the modern reader, Poe's depiction of Jupiter can seem offensive and crude, and cultural differences in the modern-day understanding of "The Gold Bug" cannot be ignored.
The cipher which Legrand translates from the parchment is, as Legrand states, a simple substitution cipher, where each letter of the alphabet is represented by a number or symbol. Legrand's use of frequency analysis to determine the cipher is a legitimate approach to solving this type of code, and his interest in breaking codes is reflected in Poe's own interest in puzzles and brainteasers. In this sense, Legrand is Poe's representative within the story, displaying Poe's penchant for irony and satire by playing with his friends' suspicions and eventually solving the case with ingenuity and clever reasoning. Although Legrand's treatise on ciphers interrupts the flow of the story, it successfully displays his intelligence and helps the narrator understand and believe the chain of Legrand's thoughts that lead to the ultimate discovery of the treasure.