Every hydrocarbon, from the simplest fuel gas to the most complex molecule in crude oil, follows a predictable formula built from just two elements: carbon and hydrogen. The most basic version is CnH2n+2, which describes the straight-chain and branched alkanes (methane, ethane, propane, and so on). From that single template, every other hydrocarbon family’s formula can be derived by subtracting pairs of hydrogen atoms each time you introduce a double bond, a triple bond, or a ring. The system is elegant and surprisingly practical once you see how it works.
The Alkane Baseline
Alkanes are the starting point because they are “saturated,” meaning every carbon atom holds as many hydrogen atoms as it possibly can. Methane has one carbon and four hydrogens (CH4). Ethane has two carbons and six hydrogens (C2H6). Propane: three carbons, eight hydrogens. The pattern is always CnH2n+2, where n is the number of carbon atoms. Plug in any value and you get the right hydrogen count. This formula works whether the carbon chain is perfectly straight or wildly branched, because branching rearranges carbon-carbon connections but does not change the total number of hydrogens.
The physical properties of these molecules shift dramatically as n climbs. With one to four carbons, alkanes are gases at room temperature: methane, ethane, propane, and butane. From about five to seventeen carbons, they are liquids, which is the range that gives us gasoline, kerosene, and diesel fuel. Beyond roughly eighteen carbons, they become waxy solids. The formula stays CnH2n+2 through all of that. What changes is molecular weight, and with it, boiling point, viscosity, and density.
What Happens When You Remove Hydrogen
Every structural feature that makes a hydrocarbon more complex than a simple alkane costs exactly two hydrogen atoms from the formula. A double bond between two carbons uses up one pair, giving you CnH2n for alkenes (like ethylene, C2H4). A triple bond costs two pairs, yielding CnH2n−2 for alkynes (like acetylene, C2H2). A ring in the carbon skeleton also costs one pair, so cyclopentane (a five-carbon ring with no double bonds) is C5H10, which matches CnH2n just like an alkene.
This “two hydrogens per feature” rule extends to molecules with multiple features. Benzene, the iconic aromatic ring, has six carbons arranged in a ring with three double-bond equivalents in its structure: one ring plus three double bonds equals four units of unsaturation, meaning eight fewer hydrogens than the corresponding alkane. The alkane with six carbons (hexane) is C6H14; benzene is C6H6, short by exactly eight hydrogens. A molecule with two rings and a double bond has lost three pairs (six hydrogens). The bookkeeping is perfectly consistent.
Degrees of Unsaturation
Chemists formalize that hydrogen-counting shortcut as “degrees of unsaturation” (sometimes called the index of hydrogen deficiency). For a pure hydrocarbon CnHh, the number of degrees of unsaturation equals (2n + 2 − h) ÷ 2. Each degree represents either one double bond or one ring; a triple bond counts as two degrees. When other elements appear in the molecule, the calculation adjusts: each halogen atom (fluorine, bromine, chlorine) subtracts one from the hydrogen count, oxygen atoms have no effect, and nitrogen atoms add one.1The Chemical Educator. An Equation for Degrees of Unsaturation
Why does this matter outside a classroom? Because if you know a molecule’s formula from, say, a mass spectrometer reading, the degree of unsaturation immediately tells you something about structure before you even look at the spectrum in detail. Zero degrees means you have a plain alkane. One degree means one ring or one double bond. Four or more degrees in a six-carbon molecule strongly suggests an aromatic ring. Analytical chemists use this as a first filter when identifying unknown compounds in petroleum, environmental samples, or forensic work.
Same Formula, Different Molecules
One of the most important things a hydrocarbon formula does not tell you is which specific molecule you are looking at. Two or more distinct compounds can share the same molecular formula but have completely different structures, different physical properties, and different reactivities. Butane and isobutane are both C4H10. Pentane, isopentane, and neopentane are all C5H12. As the carbon count rises, the number of possible arrangements explodes. There are 75 structural isomers of decane (C10H22) and over 300,000 for eicosane (C20H42).
This creates real analytical headaches. Petroleum, for example, is a mixture of thousands of hydrocarbons, many of which share the same formula. Separating and identifying these constitutional isomers requires sophisticated techniques. Gas chromatography paired with vacuum ultraviolet spectroscopy and mass spectrometry can resolve isomers based on their retention times, giving the most detailed quantitative picture of which structural isomers are present in an environmentally relevant hydrocarbon mixture.2PubMed. Improved resolution of hydrocarbon structures and constitutional isomers in complex mixtures using gas chromatography-vacuum ultraviolet-mass spectrometry
High-resolution mass spectrometry offers another approach. By measuring exact masses with extreme precision, instruments can assign a formula of the form CnH2n+Z to each detected ion, where the Z value indicates aromaticity and unsaturation. This lets analysts sort thousands of detected compounds into “compound type distributions” organized by formula class, carbon number, and the presence of heteroatoms like sulfur, oxygen, or nitrogen.3Rapid Communications in Mass Spectrometry. Exhaustive determination of hydrocarbon compound type distributions by high resolution mass spectrometry
How Petroleum Scientists Read Crude Oil by Formula
Crude oil is not one substance. It is a staggeringly complex mixture of hydrocarbons whose formulas range from methane (CH4) to molecules with fifty or more carbon atoms. Petroleum engineers classify this mixture into four broad fractions: saturates, aromatics, resins, and asphaltenes, a scheme known as SARA analysis. Saturates are the alkanes and cycloalkanes, following the familiar CnH2n+2 and CnH2n patterns. Aromatics contain one or more benzene-like rings. Resins and asphaltenes are heavier, more complex molecules that include heteroatoms alongside carbon and hydrogen.
SARA analysis has long been a standard tool for evaluating crude oil quality, but the traditional method involves labor-intensive column chromatography that takes hours. Newer high-performance liquid chromatography techniques can separate the four fractions more quickly and reproducibly, using model compounds to define precise elution windows for each class.4PubMed Central. Accelerating Saturate, Aromatic, Resin, Asphaltene (SARA) Analysis for High-Fidelity Petroleum Profiling via μSARA-HPLC Researchers have also developed machine learning models that predict SARA composition from easily measured physical properties like density and viscosity, bypassing the chromatography step entirely.5Petroleum. Estimation of SARA composition of crudes purely from density and viscosity using machine learning based models
The practical stakes are significant. A crude oil rich in light saturates (low carbon numbers, high hydrogen-to-carbon ratios) behaves very differently in a refinery than one loaded with asphaltenes (high carbon numbers, lots of rings, relatively few hydrogens). Formula distribution essentially predicts how difficult and expensive the oil will be to process into usable fuels and chemicals.
Building Hydrocarbons from Scratch
Hydrocarbon formulas are not just a way to describe naturally occurring molecules. They also guide industrial synthesis. Fischer-Tropsch synthesis, developed nearly a century ago and still used commercially, converts carbon monoxide and hydrogen gas (syngas) into liquid hydrocarbons. The reaction builds carbon chains one unit at a time, and the resulting product is a distribution of alkanes, alkenes, and other hydrocarbons whose formulas span a wide range of carbon numbers. Research on cobalt-catalyzed Fischer-Tropsch reactions has shown that surface intermediates called CHx species are involved in chain growth, and that the chain-building process is highly reversible, meaning growing chains can break apart and reassemble before a final product forms.6PubMed Central. Mechanism of Cobalt-Catalyzed CO Hydrogenation: 2. Fischer-Tropsch Synthesis
This reversibility is why Fischer-Tropsch products span such a broad formula range. You do not get just one chain length; you get everything from light gases (C1–C4) to heavy waxes (C20 and above), with the exact distribution depending on catalyst choice, temperature, and pressure. Controlling those conditions lets engineers skew the output toward gasoline-range hydrocarbons (roughly C5–C12) or toward diesel-range molecules (roughly C12–C20). The target formula range is quite literally the engineering specification.
Polycyclic Aromatic Hydrocarbons and the Environment
Not all hydrocarbon formulas are benign. Polycyclic aromatic hydrocarbons, or PAHs, are molecules built from multiple fused benzene-like rings. Naphthalene (C10H8, two fused rings) is the simplest. Benzo[a]pyrene (C20H12, five fused rings) is one of the most studied because of its cancer-causing properties. Notice how the hydrogen-to-carbon ratio drops sharply as more rings fuse together: naphthalene has a ratio of 0.8, while benzo[a]pyrene’s is just 0.6. That shrinking ratio, driven by the formula’s relentless subtraction of hydrogen with each added ring, correlates with increasing environmental persistence and biological toxicity.
PAHs are ubiquitous environmental pollutants. They form during incomplete combustion of organic matter, which means they show up in vehicle exhaust, wildfire smoke, grilled food, and industrial emissions. Their persistence in the environment, toxicity, and tendency to accumulate in living tissue make them a major class of concern for ecosystems and human health.7PubMed Central. Environmental Behavior, Toxicological Pathways, and Risk Assessment of Polycyclic Aromatic Hydrocarbons (PAHs): From Molecular Structure to Human Health The formula itself is a rough indicator of risk: higher molecular weight PAHs with more rings tend to be more persistent in soil and sediment and harder for organisms to metabolize. Environmental chemists tracking contamination often organize their findings by ring number and formula class for exactly this reason.
How Formula Connects to Fuel Performance
When you fill a car’s gas tank, you are buying a carefully tuned mixture of hydrocarbons chosen partly for their formulas. Gasoline is mostly C5 through C12 hydrocarbons. Diesel fuel sits in the C12 to C20 range. Jet fuel (kerosene) overlaps somewhere in between. But formula alone does not determine how well a fuel performs in an engine. Structure matters enormously.
Octane rating, the standard measure of gasoline’s resistance to engine knock, depends on molecular shape more than molecular size. Straight-chain alkanes like n-heptane (C7H16) knock easily and get low octane ratings. Highly branched isomers of the same formula resist knock far better. Isooctane (2,2,4-trimethylpentane, C8H18) is the reference standard for high octane. Both molecules follow CnH2n+2, but their combustion behavior inside an engine is radically different. Aromatic hydrocarbons like toluene (C7H8) also have high octane ratings, which is why refineries include some aromatics in gasoline blends despite the environmental concerns associated with compounds like benzene.
Diesel engines, by contrast, want fuels that ignite easily under compression. Straight-chain alkanes are ideal here, which is the opposite of what gasoline engines prefer. The cetane number, diesel’s equivalent of the octane number, rewards precisely the molecular features that octane ratings penalize. Same underlying formulas, completely different performance criteria depending on the engine.
Hydrocarbons Beyond Earth
Hydrocarbon formulas are not a purely terrestrial concern. Methane (CH4) has been detected in the atmospheres of Jupiter, Saturn, Uranus, Neptune, and even Mars. Saturn’s moon Titan has lakes of liquid methane and ethane on its surface. More complex hydrocarbons, including polycyclic aromatics, have been identified in interstellar dust clouds and in material recovered from meteorites.
The chemistry that produces these extraterrestrial hydrocarbons is abiological: no living organisms are needed. Carbon and hydrogen, the two most chemically versatile elements in the universe after helium, combine under the extreme conditions found in stellar outflows, nebulae, and planetary atmospheres. Astrophysical observations show that the hydrocarbons, their derivatives, and their ions detected in space are remarkably similar to the chemistry studied in terrestrial laboratories.8Journal of the American Chemical Society. Relevance and Significance of Extraterrestrial Abiological Hydrocarbon Chemistry Some researchers have explored whether meteorites and comets, carrying these hydrocarbon derivatives, delivered building-block molecules to early Earth, seeding the chemistry that eventually led to life.
The formulas involved in astrochemistry range from the simplest (CH4, C2H2) to large PAH-like structures with dozens of carbon atoms. Infrared spectroscopy of distant nebulae reveals emission signatures consistent with PAH molecules, and some estimates suggest that up to 20 percent of all interstellar carbon is locked up in PAH-type structures. The same formula rules apply whether the molecule formed in a refinery in Texas or in a gas cloud 10,000 light-years away: carbon’s four bonds and hydrogen’s one bond set the math, and the rest follows.
When the Formula Gets Decorated
Strictly speaking, a hydrocarbon contains only carbon and hydrogen. But in practice, the hydrocarbon formula framework is constantly extended to include heteroatoms: atoms other than carbon and hydrogen, most commonly oxygen, nitrogen, and sulfur. Natural gas contains small amounts of hydrogen sulfide (H2S). Crude oil includes sulfur-containing thiophenes and nitrogen-containing pyridines alongside its pure hydrocarbons. Biofuels like ethanol (C2H5OH) are hydrocarbons with an oxygen atom tacked on.
The degrees-of-unsaturation formula adjusts neatly for these additions. As noted earlier, halogens reduce the effective hydrogen count by one each, oxygen atoms have no effect, and nitrogen atoms increase it by one.9The Chemical Educator. An Equation for Degrees of Unsaturation This means a chemist can look at a molecular formula like C8H10N4O2 (caffeine, as it happens) and calculate four degrees of unsaturation, correctly predicting that the molecule contains rings and double bonds even before examining any spectral data. The hydrocarbon formula framework is the scaffold; heteroatoms are the decorations that sit on top of it.
High-resolution mass spectrometry in petroleum analysis exploits exactly this idea. Instruments sort detected ions by the general formula CnH2n+ZSaObNc, where the Z value captures aromaticity and the subscripts capture heteroatom content.10Rapid Communications in Mass Spectrometry. Exhaustive determination of hydrocarbon compound type distributions by high resolution mass spectrometry The output is essentially a map of everything in the sample organized by formula type, aromaticity, and molecular weight. A single crude oil sample can produce thousands of distinct formula assignments, each one a point on that map. The hydrocarbon formula, extended with a few extra subscripts, becomes the coordinate system for understanding one of the most complex natural mixtures on the planet.

