The film is a very loose adaptation of the one-act opera Bluebeard's Castle () by the Hungarian composer Béla Bartók, with the libretto adapted by Béla Balázs from the folktale "Bluebeard" by 17th-century French writer Charles Perrault. Kékszakállú has few similarities with the narrative of the opera, as Solnicki was not interested in "matching" the characters or "imitating the story", preferring rather to find the "cinematic materials" in the opera. Solnicki commended Bartók's audacity in adapting the structure of Perrault's tale to his own needs, noting that in Bartók's version, Bluebeard is "not the monster but the victim."
