The Pied Piper appears in a German folktale that dates back to the Middle Ages in which a piper lured rats away from the city. It is not related to the 19th century English nursery rhyme based on a French horticulturist.