Compute a molecular formula's weight
Exactchemistry_formula_weightDeterministic and authoritative — the canonical answer for this input.
Compute a molecular formula's weight and composition, fully locally (no upstream call). Parses nested parentheses/brackets and multipliers (e.g. 'C9H8O4', 'Ca(OH)2', 'Fe2(SO4)3') and returns molecular weight, monoisotopic weight, per-element counts, and mass composition. Unparseable formula or unknown element -> confidence 0.0. Batch via chemistry_formula_weight_batch. Charges 1 cost_unit.
Parameters
formulastringrequiredThe molecular formula to weigh (e.g. 'C9H8O4', 'Ca(OH)2').
Call it
curl -X POST https://api.snipget.ai/v1/chemistry/formula/weight \
-H "Authorization: Bearer sk_live_..." \
-H "Content-Type: application/json" \
-d '{"formula":"C9H8O4"}'The Batch tab sends up to 1000 inputs in one call via /v1/chemistry/formula/weight/batch.
Example response
{
"input": "C9H8O4",
"formula": "C9H8O4",
"is_valid": true,
"molecular_weight": 180.1578,
"element_counts": {
"C": 9,
"H": 8,
"O": 4
},
"element_composition_pct": {
"C": 60.0011,
"H": 4.4758,
"O": 35.5231
},
"monoisotopic_weight": 180.0423
}FAQ
Why not just have a model add up the atomic weights?
Models routinely miscount atoms inside parentheses or use stale atomic weights. This parses nested groups (Ca(OH)2, Fe2(SO4)3) correctly and uses bundled IUPAC/CODATA atomic weights, so the molecular weight is right every time.
What does it give me back?
The average molecular weight, the monoisotopic weight, a per-element atom count, and the percent mass composition by element. It runs fully offline.
Is the answer exact?
Yes. It is a deterministic calculation from a fixed atomic-weight table, so the same formula always returns the same numbers.
How is this different from exact_mass?
This gives the average molar mass you weigh on a balance. Use chemistry_exact_mass when you need the monoisotopic mass and ion m/z for mass spectrometry.
What if my formula has a typo or a made-up element?
An unparseable formula or an unknown element comes back with confidence 0 and a why_invalid reason, not an error, so a bad input never silently produces a wrong weight.