There is no one chemical formula for granite. Granite is a rock and is therefore composed of several types of minerals. Granite is mostly alkali feldspar and quartz, with other minerals being accessories or accidentals.
The chemical formulas for alkali feldspars include KAlSi3O8, which is orthoclase; (K,Na)AlSi3O8, which is sanidine; and KAlSi3O8, which is microline. Another alkali feldspar is anorthoclase, whose formula is (Na,K)AlSi3O8. The chemical formula for quartz is SiO2.
Other minerals can give granite its great variety of colors and textures. These other minerals include mica, amphibole, hornblende, biotite and muscovite.
Granite is a plutonic, igneous rock. It's formed in underground magma chambers and slowly works its way up to the Earth's crust.