Andersen wrote (or in some cases merely adapted) about thirty plays of very different kinds, partly revues for the Student's Association (where he sometimes acted himself), partly plays for the Royal Theatre and from 1849 for the newly established popular theatre, the Casino (both in Copenhagen).

Of his opera texts special mention must be made of the text for his and J.P.E. Hartmann's opera Liden Kirsten (Little Kirstin) (first performed in 1846), which became a sort of Danish national opera till the advent of Carl Nielsen's Maskerade (1906). Andersen persuaded Franz Liszt to put on Liden Kirsten at the theatre in Weimar in 1856 (with the title Klein Karin).