Cantatas and operas are both forms of vocal music with instrumental accompaniment which involve drama, and both were born in Italy during the Baroque period (1600-1750). They are easily confused, but there are several points of distinction.
An opera is intended to be acted out, as a play in which all of the dialogue is sung rather than spoken. A cantata, on the other hand, is also a drama, but is more like a story set to music and sung.
Sources and Origins
Operas generally take their story from mythology, whereas a cantata can often be a sacred piece, similar to an oratorio but shorter in length. Cantatas can, however, be derived from a lyric drama as well.
Cantatas were intended as chamber music, a performance delivered by a smaller group to a more intimate audience (such as at a private). Unlike chamber music, opera is generally performed in a theater to a much larger audience.
As chamber music, cantatas were originally written for one voice on each part. As the form moved into the church, it became a series of movements, some for soloists and some for an entire chorus. The number of parts in an opera depends on the number of parts in the play.
Cantatas can be seen as a sort of minimalistic opera. Opera is at the extreme with all its sets, costumes and acting. Oratorio is in the middle, less dramatic than opera, with no sets or costumes but a large chorus for the voices. Cantatas are like oratorio, but with far fewer voices.