Barrie created Peter Pan in stories he told to the sons of his friend Sylvia Llewelyn Davies, with whom he had forged a special relationship. Mrs. Llewelyn Davies' death from cancer came within a few years after the death of her husband. Barrie was named as co-guardian of the boys and unofficially adopted them.
The character's name comes from two sources: Peter Llewelyn Davies, one of the boys, and Pan, the mischievous Greek god of the woodlands. It has also been suggested that the inspiration for the character was Barrie's elder brother David, whose death in a skating accident at the age of thirteen deeply affected their mother. According to Andrew Birkin, author of J.M. Barrie and the Lost Boys, the death was 'a catastrophe beyond belief, and one from which she never fully recovered... If Margaret Ogilvy [Barrie's mother as the heroine of his 1896 novel of that title] drew a measure of comfort from the notion that David, in dying a boy, would remain a boy for ever, Barrie drew inspiration.'
Peter Pan first appeared in print in a 1902 book called The Little White Bird, a fictionalised version of Barrie's relationship with the Llewelyn Davies children, and was then used in a very successful stage play, Peter Pan, or The Boy Who Wouldn't Grow Up, which premiered in London on December 27, 1904.
In 1906, the portion of The Little White Bird which featured Peter Pan was published as the book Peter Pan in Kensington Gardens, with illustrations by Arthur Rackham. Barrie then adapted the play into the 1911 novel Peter and Wendy (most often now published simply as Peter Pan).
The original draft of the play was entitled simply Anon: A Play ('Anon' being a name Barrie used in reference to himself). Barrie's working titles for it included The Great White Father and Peter Pan, or The Boy Who Hated Mothers. Producer Charles Frohman disliked the title on the manuscript, in answer to which Barrie reportedly suggested The Boy Who Couldn't Grow Up; Frohman suggested changing it to Wouldn't
— Excerpted from Wikipedia, the free encyclopedia.