How can an Organic chemist know the chemical formula of a natural product she isolated from an organism? As a non scientist I several times wondered how can an Organic chemist successfully isolate a single molecule which a natural product of an organism;
Whether a plant-part/mushroom-part/algae-part or a coral-part or even from an animal or human organ in autopsy (neurotransmitter/hormone and so forth).

I also wondered how could she go further to know the natural product's (exact?) chemical formula and give such newly discovered molecule a name.

Given that molecules are such small entities, way smaller than the smallest uicellular organism and are hard to be photographed uniquely with current microscopal technologies (AFM/STM); it is unclear to me How could she know if a plant part contains a certain molecule (say caffeine or nicotine) so precisely that she could tell:


  This is what I will now name Caffeine → not Theobromine
  or any other Methylxantine → just Caffeine, pure and exact and unequivocal.


Practical examples for my problem are:


How did organic chemists isolated THC from various Cannabis plant-parts and gave it a formula and a name, although today it is known that Cannabis plant parts has tens of cannabinoids?
How did organic chemists isolated Ganodermadiol in some Ganodrma mushroom part/s and gave it a chemical formula and name and claimed it is similar to steroidal hormones?
How did they know they weren't wrong?


My question

How can an Organic chemist know the chemical formula of a natural product she isolated from an organism?
How can an Organic chemist know the chemical formula of a natural product she isolated from an organism?


There are two levels of answers. One is historical and one is modern. Historically, determining the chemical formula for had been a trivial job for most small or medium sized molecules. You do a combustion analysis, determine how much carbon dioxide, and water were produced. By doing other classical element detection tests, you would determine if it had halogens, nitrogen and sulfur. These were the most common approaches. The determination of molecular weights was done by classical physical chemistry experiments.

Today you would still do combustion analysis and elemental analysis as a first step and determine the CHNS ratios. Then you run a mass spectrum of the compound, and assess the molecular weight of the compound. 

Determining a structural formula may take a long time and others have already mentioned in the comments. Today advanced NMR techniques, high resolution mass spectrometry, X-ray of crystals (if they exist), all help in structure determination. These things have become routine now.

Nobody routinely determines the molecular structure by AFM or STM as far as I know.