Soaps are basically the substances which on dissolving in water, possess the ability to remove dirt particles from the surfaces such as: human skin, textiles, fabrics etc.
Soap is actually the Sodium or Potassium salts of the fatty acids which are formed by the process known as saponification.
It consist of a chemical structure in which their molecules contain a hydrophobic part that is known as water insoluble part .
It also consists of a hydrophilic part which is basically the water soluble part and this hydrophilic part in the structure of soap is the reason for solubility of soap in water.
So basically, the chemical formula of soap is , where denotes any long-chain alkyl group containing 12 to 18 carbon atoms.
Some of the examples of soap with their chemical formula: