The writing of the film script involved three different authors, including the American novelist William Faulkner. The writing was influenced by a primary focus of the Hays Office censorship policies which were often used to heavily restrict sexual themes. In the novel, Geiger is selling pornography, then illegal and associated with organized crime, and is also a homosexual having a relationship with Lundgren. Likewise, Carmen is described as being nude in Geiger's house, and later nude and in Marlowe's bed. To ensure the film would be approved by the Hays Office, changes had to be made. Carmen had to be fully dressed, and the pornographic elements could only be alluded to with cryptic references to photographs of Carmen wearing a "Chinese dress" and sitting in a "Chinese chair". The sexual orientation of Geiger and Lundgren goes unmentioned in the film because references to homosexuality were prohibited. The scene of Carmen in Marlowe's bed was replaced with a scene in which she appears, fully dressed, sitting in Marlowe's apartment, when he promptly kicks her out. The scene, shot in 1944, was entirely omitted in the 1945 cut but restored for the 1946 version.
The Big Sleep is known for its convoluted plot. During filming, allegedly neither the director nor the screenwriters knew whether chauffeur Owen Taylor was murdered or had killed himself. They sent a cable to Chandler, who told a friend in a later letter: "They sent me a wire ... asking me, and dammit I didn't know either".
After its completion, Warner Bros. did not release The Big Sleep until they had turned out a backlog of war-related films. Because the war was ending, the studio feared the public might lose interest in the films, while The Big Sleep's subject was not time-sensitive. Attentive observers will note indications of the film's wartime production, such as period dialogue, pictures of President Franklin D. Roosevelt, and a woman taxi driver, who says to Bogart, "I'm your girl." Wartime rationing influences the film: dead bodies are called "red points", which referred to wartime meat rationing, and Marlowe's car has a "B" gasoline rationing sticker in the lower passenger-side window, indicating he is essential to the war effort and therefore allowed eight gallons of gasoline per week.
The "Bogie and Bacall" phenomenon, a fascination with the couple that had begun with To Have and Have Not, and that grew during their subsequent marriage, was in full swing by the end of the war. Bacall's agent, Charles K. Feldman, asked that portions of the film be re-shot to capitalize on their chemistry and counteract the negative press Bacall had received for her 1945 performance in Confidential Agent which was released prior to The Big Sleep even though produced after it.
Producer Jack L. Warner agreed, and new scenes for The Big Sleep, such as the sexually suggestive racehorse dialogue, were added (scripted by an uncredited Julius Epstein). The re-shot ending featured Peggy Knudsen as Mona Mars because Pat Clark, the originally cast actress, was unavailable. Furthermore, the parts of James Flavin and Thomas E. Jackson were completely eliminated. Because of the two versions created by the re-shooting, there is a substantial difference in content of some twenty minutes between them, although the difference in running time is two minutes. Novelist Raymond Chandler said Martha Vickers (Carmen) overshadowed Lauren Bacall (Vivian) in their scenes together, which led the producers to delete much of Vickers' performance to enhance Bacall's.