Empirical formula from masses calculator
Turn weighed element masses and the atomic masses from your worksheet into an empirical formula: 40 g of carbon, 6.7 g of hydrogen and 53.3 g of oxygen give CH2O. Every step, from moles to ratios, is shown. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
Runs in your browser. Free, unlimited — your data never leaves this page.
An empirical formula is the simplest whole-number ratio of atoms in a compound, and the classic laboratory path to it starts from measured masses of each element together with the atomic masses you were given or looked up. Divide every mass by its atomic mass to obtain moles, divide those moles by the smallest mole amount, then multiply by the smallest integer that clears the decimals to integer subscripts. Zero atomic mass is rejected as invalid input because moles are undefined under division by zero.
Classroom use and practical limits
Call the free in-browser empirical formula from masses calculator for homework checks, lecture demos, and quick verification of lab arithmetic without installing a spreadsheet or chemistry CAS. Because atomic masses are caller-supplied, you can use textbook two-decimal tables, four-decimal standard weights, or isotopic masses for advanced exercises without waiting for a catalog update. Keep magnitudes within published bounds, prefer classroom-scale inputs for grading oracles, and treat source inputs under the same retention rules as other KIT parse items.
Authors shipping SDKs can map the elements array directly into UI tables that show mass, atomic mass, moles, ratio, and count—the same columns students build by hand when they derive an empirical formula from experimental masses.
What you can do with it
Homework and lab report checks
Students enter measured element masses and the atomic masses from their worksheet, compare mole ratios and the empirical formula string, and see a clear error if atomic mass is left at zero.
FAQ
How do I compute an empirical formula from masses?
The response includes moles, mole ratios, integer counts, and the formula string.
What happens if atomic mass is zero?
Atomic mass must be greater than zero because moles equal mass divided by atomic mass; zero is rejected and not charged.
Do I need a built-in periodic table?
No. You supply atomic masses yourself, so textbook tables, lab sheets, or isotopic masses all work without a fixed catalog.
Is the empirical formula from masses calculator free?
The browser tool runs free on your device.
Which atomic masses should I use?
Use the ones your worksheet or textbook gives, so your answer matches the key. Because you supply them, two-decimal textbook tables, four-decimal standard weights and isotopic masses for advanced exercises all work.
Related tools
For developers — API access
Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.
API endpoint
Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.
Call it from your stack
curl -X POST https://api.kit.forhosting.com/chem/empirical-from-masses \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"elements":[{"symbol":"C","mass":40,"atomic_mass":12.011},{"symbol":"H","mass":6.7,"atomic_mass":1.008},{"symbol":"O","mass":53.3,"atomic_mass":15.999}]}'const res = await fetch("https://api.kit.forhosting.com/chem/empirical-from-masses", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"elements": [
{
"symbol": "C",
"mass": 40,
"atomic_mass": 12.011
},
{
"symbol": "H",
"mass": 6.7,
"atomic_mass": 1.008
},
{
"symbol": "O",
"mass": 53.3,
"atomic_mass": 15.999
}
]
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/chem/empirical-from-masses",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"elements": [
{
"symbol": "C",
"mass": 40,
"atomic_mass": 12.011
},
{
"symbol": "H",
"mass": 6.7,
"atomic_mass": 1.008
},
{
"symbol": "O",
"mass": 53.3,
"atomic_mass": 15.999
}
]
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/chem/empirical-from-masses", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"elements":[{"symbol":"C","mass":40,"atomic_mass":12.011},{"symbol":"H","mass":6.7,"atomic_mass":1.008},{"symbol":"O","mass":53.3,"atomic_mass":15.999}]}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"elements":[{"symbol":"C","mass":40,"atomic_mass":12.011},{"symbol":"H","mass":6.7,"atomic_mass":1.008},{"symbol":"O","mass":53.3,"atomic_mass":15.999}]}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/chem/empirical-from-masses", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"elements": [
{
"symbol": "C",
"mass": 40,
"atomic_mass": 12.011
},
{
"symbol": "H",
"mass": 6.7,
"atomic_mass": 1.008
},
{
"symbol": "O",
"mass": 53.3,
"atomic_mass": 15.999
}
]
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "chem.empirical_from_masses",
"status": "queued",
"_links": {
"result": "/tasks/tsk_…/result"
}
}The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.
Pricing
Published price — no tokens, no invented credits. A failed task is never charged.
Errors
| HTTP | Code | Meaning |
|---|---|---|
401 | unauthorized | Missing or invalid API key. |
402 | insufficient_balance | Your balance doesn't cover the task price. |
404 | unknown_type | That task type doesn't exist. |
429 | rate_limited | Too many requests. Use the webhook instead of polling. |
Technical notes
This capability does that arithmetic deterministically from your numbers alone—no built-in periodic table required—so homework, lab reports, and teaching pipelines can plug in textbook atomic weights or experimental relative masses and pin the JSON output in tests.
Inputs: masses, atomic masses, and how mole ratios are formed
Masses must be non-negative; at least one mass must be positive so the sample is not empty. Moles for each entry equal mass divided by atomic mass. Identical inputs always produce identical outputs because the path is pure arithmetic with no network, no random seed, and no wall clock. Send an elements array where each object carries mass and atomic_mass as finite numbers, plus an optional symbol or label for the formula string. Atomic mass must be strictly greater than zero—any zero atomic mass fails with invalid_input and is not charged, matching the product promise that division by zero is never silently replaced with infinity or NaN. You may also send parallel arrays masses and atomic_masses of equal length, with optional symbols for display labels. The engine finds the minimum positive mole amount, forms mole ratios by dividing every mole value by that minimum, and records those ratios with stable rounding for reproducible JSON. Cap the list at a modest element count so Worker isolates stay safe while still covering every classroom multi-element example and most research-style composition tables students type by hand from gravimetric analysis.
Reading formula, counts, ratios, and multiplier in the response
On success the response includes formula, a Hill-ordered string when symbols look like standard element symbols, otherwise labels in input order with integer subscripts after each symbol when the count is greater than one. The elements array lists each active component with mass, atomic_mass, moles, mole_ratio relative to the smallest mole amount, and count after integer reduction. The multiplier field is the integer scale factor applied before reducing by greatest common divisor so the empirical formula is the lowest whole-number ratio. total_mass echoes the sum of supplied masses for quick sanity checks against a lab notebook total, and method is always mass_atomic_mass_mole_ratio so downstream code can branch without sniffing shapes. Use mole_ratio alone when grading software only checks the intermediate step after dividing by the smallest moles; use count and formula when the rubric wants the final empirical formula; use the full elements table when a UI shows a worked solution step by step. Missing required fields, unequal parallel-array lengths, non-finite numbers, all-zero masses, negative masses, and zero atomic mass all fail with invalid_input.
API usage, pricing, classroom workflows, and practical limits
Pair this endpoint with percent-composition tools when students start from percentages rather than absolute masses, or with molar-mass calculators when the next step is converting an empirical formula into a molecular formula using an experimental molar mass.
Integration use cases
Tutoring and auto-graded drills
Lesson builders generate composition problems with fixed atomic-mass tables and grade structured JSON counts without embedding a full chemistry engine.
LIMS and composition pipelines
Scripts that already store masses and atomic weights call a stable prepaid endpoint to attach empirical formulas to sample records.
Technical questions
Can I send parallel mass and atomic_mass arrays?
Yes. Provide masses and atomic_masses of equal length, and optionally symbols for formula labels, instead of an elements object array.