system
Given the following post, respond as if you're commenting on Reddit:
human
[ELI5] How do scientists figure out how much protein, carbs, vitamins, etc. are in a food?

Do they just test the food directly, or do they test your blood afterwards to see how much you've changed from a baseline?  How about vitamin pills-- do they ever do a blood test to determine how much of the vitamins gets absorbed?
gpt
Ok, so first we'll address proteins, carbs, and fats.  Fats, which are like butter, oil, or the white stuff around a steak, can't combine with water.  So, we weigh how much the food weighs at first, then we use a solution called "ether," which is kind of like scientist's dawn, to wash away the fat from the food.  Then we weigh the food again & figure out how much is left.  Then we subtract how much is left to how much we started with & that gives us how much fat is in the food.

Carbs & proteins are trickier since they are both water soluble.  For proteins, we can't directly measure proteins like we can for fat & instead measure a substance called nitrogen, which is another pure element like oxygen & carbon.  We measure nitrogen because all proteins contain nitrogen.  Now, to find the amount of nitrogen in a food, we mix the food with sulfuric acid, which is like the acid that we see on cartoons that eats almost everything it touches.  This sulfuric acid will make ammonia, which is that smell made by cleaning products.  We then measure the amount of ammonia made & that tells as how much nitrogen and, therefore, protein is in the food.

Carbs are fun to measure because we essentially put the food sample into a small washing machine & add different detergents to figure out how many carbs are in the food.  Like when finding fat, we measure how much food we started with, then how much food we ended with, subject one from the other & find out how much of the food was carbs.  (DO NOT PUT FOOD IN THE WASHING MACHINE!)

For vitamins & minerals, there are individual different methods for each vitamin & mineral.  For minerals, we can either do wet chemistries or atomic absorption spectroscopy (AAS).  Wet chemistries which is we a scientist will add different solutions to the food till a chemical reaction occurs, like a change of color or a formation of a solid in a liquid solution.  AAS is when we put the ash, or burnt up remains of the food, into water.  We then fire a beam at the water & measure the light bounced out of the water, kind of like a prism.  The color & amount of the light reflects what type & how much of mineral is present.

For vitamins, every vitamin is a bit different.  Often times, though, we compare a solution with a known certain of the vitamin to the food solution & calculate the difference between the two.  Ask me when you're 10 for specifics.

We don't test the blood after we eat a food because there are so many differences between people that it would not tell us how much of something is actually in a food.

For vitamin pills, we do sometimes due "bioavailability" studies,  which essentially looks at how easily a pill is used by the body instead of just getting pooped out again.