I use StarSan to sanitize my equipment, and if you have ever used the product, you have noticed that it creates a lot of foam. The foam is often difficult to get out of the fermenter or carboy, and looks scary to first time users.
I too was a bit concerned by the amount of foam in my carboys and kegs, so I searched the homebrew forums and read over and over again that there is no reason to be concerned about it. Over and over, from several brewers, I read “don’t fear the foam”.
So, I let go of my concerns, and just racked into the carboys and kegs, and they are right. As you can see by this photo, the wort will just push the foam out of the carboy/keg. For the little bit that remains, the amount is negligible. In fact, some even suggest that in the tiny amount present, it may actually aid fermentation.