Foam is a combination of protein and polysaccharides (e.g. starch). This is why many beers have thick persistent heads of foam.
Root beer makers add things to help increase the foam. The root extracts in traditional root beer likely added some of these things. Colas contain cola/kola nut extracts.
For home soda makers you can buy products like this: https://www.sodacentre.com/products/beer-heading-powder-25g
Many sodas are just flavor, acid, and sugar/sweetener. So nothing to keep a head of foam stabilized.
Latest Answers