Writer Howard Gordon was initially inspired to write this episode based on insomnia he was suffering at the time. Gordon, who wrote many episodes with Alex Gansa in season one made his solo writing debut with this episode. Originally Chris Carter had written a script for the first season, which shared the same theme as "Sleepless." The original conceit for Carter's episode was "What makes the perfect soldier?" He also liked the twist on sleep, noting that "sleep is where demons are released in our dreams." He explained that the characters in "Sleepless" were haunted by their memories in real life because they were not able to sleep. Carter sees this episode as one of his favorites.