A pastry bag is used to pipe semi-solid foods (including cake decoration) - for many purposes - by forcing (extruding) them through a narrow opening at one end. It is filled through a wider opening at the opposite end, then rolled or twisted closed, and finally squeezed to push out its contents.
Though a circular nozzle is quite useful for making standard tube shapes and for filling pastries such as profiteroles, many differently-shaped nozzles are commonly used to produce star, leaf, and flower-petal shapes.
Icing decorations are produced using a pastry bag. However, aside from icing, pastry bags are commonly used to shape meringue and whipped cream, and to fill doughnuts with jelly or custard. When presentation is especially important, fluted tips can be used to shape savoury foods such as fillings for devilled eggs, whipped butter, and mashed potatoes (especially for Pommes duchesse).
A high-quality bag is often made from nylon, polyester, or waterproofed cotton, with a collection of interchangeable chrome-plated or stainless steel tips. Each tip is cone-shaped, the base of which is too large to fit through the small opening in the bag so that it doesn't come out while piping. The tips have be inserted through the larger opening before the food is spooned in. Less expensive models are generally made out of plastic film or sheeting with screw-on plastic tips (see image, above), while many foods (including frosting and �pressurisedl� "spray can" whipped cream) can be purchased in disposable packaging designed to serve the same function as a pastry bag.
A simple one-time-use-only pastry bag can be made by rolling cooking parchment/baking paper/wax paper into a cone, filling it, folding the wide end several times to close it, and then cutting the tip with scissors or sharp knife into whatever shape is desired. This is especially useful for small quantities of melted chocolate, since a very small hole can be cut and the bag can be discarded when it cools and therefore becomes clogged. The paper can be unwrapped and solidifed chocolate can be recycled and put into the main melting pot.