The phrase to count sheep means to count imaginary sheep jumping over an obstacle one by one, as a way of sending oneself to sleep.
The earliest occurrence of the image that I have found is from Getting Over the Difficulty1, by the American author Seba Smith (1792-1868), published in the Buffalo Christian Advocate (Buffalo, New York) of Thursday 29th April 1852; John Van Ben Schoten is telling to the narrator the story of Peter Van Horn, who is about to get married:
“Thus far, up to the evening before the wedding day, everything looked fair and promising. Peter retired to bed early, in the hope of getting a good night’s rest; but somehow or other he never was so restless in his life. He shut his eyes with all his might, and tried to think of sheep jumping over a wall; but do all he could, sleep wouldn’t come.”
(1 This story was republished under the title A Dutch Wedding in ’Way down East; or, Portraitures of Yankee Life (New York, 1854).)
The earliest instance that I have found of to count sheep—albeit in an extended form—is from A Discourse on the Iron Horse and the Vulgarity of Coal and Steam. A Night on the New York Central Sleeper Described—Woman’s Selfishness, by Kate Field, published in The Courier-Journal (Louisville, Kentucky) of Sunday 22nd August 1886:
Thus does the nervous woman try the “mind cure.” It is a lamentable failure. Her faith is not equal to the occasion, and she lies awake counting sheep jumping over a stone wall until dawn, when exhausted nature closes her eyes.
And the earliest occurrence of the shortened form that I have found is from A Brother’s Gift, a story by Julia Clarke Chase, published in The Weekly Wisconsin (Milwaukee, Wisconsin) of Saturday 3rd May 1890:
One night I had a return of the terrible insomnia which had persecuted me for the last year in school. I lay wide awake, thinking of everything, and nothing; tossing, turning, saying prayers, counting sheep, turning my eyeballs down, reciting poetry aloud, and trying all the other things people imagine will bring sleep to the staring eyes and aching brain.
Julia Clarke Chase probably alluded to the sort of advice that the medical profession was giving at that time to help people to fall asleep; for instance, the following is a passage from Insomnia, published in The Eclectic Medical Journal (Cincinnati, Ohio) of October 1888:
Among the devices found to control insomnia we may mention the water-drip. The sound of water dropping slowly and steadily into a pan occupies and quiets the brain. This is the principle on which we are told to count sheep going over a fence, and do any sort of automatic thinking if such an expression be permissible. A former victim of insomnia cured himself by keeping the eyeballs looking down. Another keeps rolling them in one direction with good effect, repeating, meanwhile, a certain word or number.
The equivalent French phrase is compter les moutons, to count the sheep. The earliest instance that I have found—in an extended form—is from Cure d’insomnie (Insomnia Cure), published in Comœdia (Paris) of Monday 10th January 1927:
Tout le monde connaît ces procédés innocents contre l’insomnie qui consistent à répéter indéfiniment la phrase ou à compter les moutons d’un troupeau imaginaire jusqu’à ce que l’esprit, engourdi par cette occupation monotone, sombre dans l’inconscience.
Voici qu’un séduisante actrice américaine, l’idole des Etats-Unis, Miss Elsie Janis, a trouvé mieux.
— Quand je ne peux pas dormir, dit-elle avec un suave petit accent, je m’amuse à compter sur mes doigts tous les hommes qui m’ont aimée… Toujours je m’endors avant la fin…
Mesdames les insomnieuses, si le cœur vous en dit… Mais le remède sera-t-il du goût des maris ?
Everyone knows those innocent methods against insomnia which consist in repeating indefinitely the sentence or in counting the sheep of an imaginary flock until the mind, numbed by this monotonous occupation, sinks into unconsciousness.
But a seductive American actress, the United States’ idol, Miss Elsie Janis, has found better.
— When I cannot sleep, says she with a suave little accent, I count on my fingers all the men who loved me… Always I fall asleep before the end…
Insomniac ladies, if you feel like it… But will the remedy be to the husbands’ taste?
The form compter des moutons, to count sheep, has also been used, as in the following from L’Écho du Sud (Fianarantsoa, Madagascar) of Saturday 12th March 1938:
Remède contre l’insomnie
En comptant les moutons
Je ne suis pas un homme sanguinaire. Tout ce que je demande c’est de rencontrer la personne bien intentionnée mais folle, qui conseille à ceux que l’insomnie torture de compter des moutons pour trouver le sommeil. Je le répète, je ne suis pas sanguinaire et je ne demande rien de plus que de conduire cette personne dans une ferme déserte et de l’assommer à coups de côtelettes de mouton !
Remedy against Insomnia
While counting the sheep
I am not a bloodthirsty man. All I am asking for is to meet the well-intentioned but mad person, who advises those that insomnia tortures to count sheep in order to find sleep. I say it again, I am not bloodthirsty and I am asking for nothing more than to lead this person into a desert farm and to knock him out with a mutton2 cutlet!
(2 When used as a countable noun, the French word mouton translates as sheep; when used as a mass noun, it translates as mutton.)
In this cartoon, titled Let’s Try Counting Sheep, Adolf!, Adolf Hitler (1889-1945) and Joseph Goebbels (1897-1945) are unable to find sleep because of the bears (i.e. the Russians) that they see in their imagination—from The Evening Sun (Baltimore, Maryland) of Monday 26th January 1942: