From Writers in the Storm:
Know Your Audience
Not everyone has the same sense of humor. One person’s mirth may be another’s eye-roll. The reader’s age is important to take into consideration. Something funny to a teen or adult will not necessarily work for a young child—although bathroom humor—which starts very early in life, never seems to get old.
It’s helpful to have a feel for your readers’ expectations.
Jim Butcher’s fantasy/mystery series, The Dresden Files, is full of humor—sarcastic as well as oddly motivational. The following quote in which detective and wizard Harry Dresden interacts with medical examiner Waldo Butters is from Dead Beat, number 7 in the series.
“‘We are not going to die.’
Butters stared up at me, pale, his eyes terrified. ‘Were not?’
‘No. And do you know why?’ He shook his head. ‘Because Thomas is too pretty to die. And because I am too stubborn to die.’ I hauled on the shirt even harder. ‘And most of all because tomorrow is Octoberfest, Butters, and polka will never die.’”
Create Comedy using Repetition
Like the knock-knock joke, repetition with a surprise ending formula can work for prose. Here is an example by essayist David Sedaris from his collection Naked showing comedy through surprise.
“The first two times I read the book, I found myself aching with pleasure. Yes, these people were naughty, but at the age of thirteen, I couldn’t help but admire their infectious energy and spirited enjoyment of life. The third time I came away shocked, not by the characters’ behavior but by the innumerable typos.”
Link to the rest at Writers in the Storm