One of the main components of fire is oxygen but since there is no oxygen in space how does the sun burn?
The sun doesn’t burn. It is a nuclear reaction that is converting lighter elements into heavier elements, producing heat and light in the process. Like we do with nuclear fusion reactors, the Suns gravity and energy is so strong that it is a giant reactor. Oxygen actually gets created during so stages of this process, but is not needed for the reaction.
Indeed, fire is a chemical reaction, in most practical cases a hydrocarbon of some sort reacting to oxygen. What the sun does is nuclear fusion, atoms being smashed together to form denser particles. This process requires no oxygen, or indeed any particular element.
Nuclear fusion needs isotopes of elements and in the suns case isotopes of hydrogen to cause the fusion into elements. This fusion is what fuels the sun and keeps us warm. The fusion produces a lot of heat and light as well as radiation. The earth itself protects us from the radiation but allows that heat and light to get in.
By chance I saw the headline of this topic and looked at the question and its very thought provoking considering fire needs oxygen but the answers are equally as good since the fusion even creates oxygen too, wow our universe is something special!