Chorale fantasia is a type of large composition based on a chorale melody, both works for organ, and vocal settings, for example the opening movements of Bach's chorale cantatas, with the chorale melody as a cantus firmus.
Chorale fantasias first appeared in the 17th century in the works of North German composers such as Heinrich Scheidemann and Franz Tunder (who, however, rarely used the term). Their works would treat each phrase of a chorale differently, thus becoming large, sectional compositions with elaborate development of the chorale melody. By mid-18th century this type of organ composition was practically non-existent.
Johann Sebastian Bach used the term first to designate a whole variety of different organ chorale types (during his period in Weimar), and then limited its use to large compositions with the chorale melody presented in the bass. Bach also wrote movements which have been described as chorale fantasias scored for various combinations of singers and instruments, for example the opening choruses of his chorale cantatas and the closing movement of Part I of the St Matthew Passion. In the vocal pieces the chorale cantus firmus is often given to an upper voice.
In the 19th century the chorale fantasia was revived by Max Reger, who applied the term to monumental pieces based on chorale melodies.