ForHosting KIT · Science

Mole fraction calculator

In a mixture of 2, 3 and 5 moles, the first component's mole fraction is 0.2. Enter the moles of every component, pick one, and get its share along with the whole composition, ready for Raoult's or Dalton's law. Free in your browser.

  • Free
  • Runs in your browser
  • No sign-up
  • Your data stays on your device
Use it from WebAPIEmailTelegramApp soon

Runs in your browser. Free, unlimited — your data never leaves this page.

Mole fraction is the composition measure that expresses how much of a mixture is one substance on a molar basis. Because the ratio is dimensionless, mole fractions always sum to one when every species is counted, and they appear directly in Raoult's law, Dalton's law of partial pressures, ideal-solution free energy, and gas equilibrium constants. Students first drill binary mixtures such as two moles of A and three of B giving x_A equals two fifths, then move to multi-component process streams and gas analyses. This calculator accepts an ordered list of component moles and a zero-based index for the substance of interest, returns the chosen mole fraction plus the full composition vector, total moles, and the formula string for audit, and rejects a zero total so a bad denominator never becomes Infinity or NaN.

Where mole fraction calculators show up in real work

Secondary-school and university chemistry courses assign composition drills that convert mass data into moles and then into mole fractions for binary and ternary mixtures; a single trusted oracle speeds grading and demo setup without hand-waving floating-point noise. Process engineers and plant chemists convert laboratory gas-chromatography mole amounts into stream compositions before feeding flash, distillation, and reactor models that expect x and y vectors. Environmental and atmospheric notebooks normalize measured species inventories into mole fractions for ideal-gas partial-pressure and mixing-ratio work.

Materials and polymer labs report copolymer feed compositions on a mole-fraction basis so stoichiometry and conversion calculations stay consistent with kinetic models. If you later need mass fraction from masses, molality from moles and solvent kilograms, molarity from volume, or automatic gram-to-mole conversion with a built-in molar-mass table, treat those as separate search intents and landings rather than overloading this mole-fraction calculator page.

Process stream composition

Normalize measured component mole amounts into mole fractions before flash, distillation, or reactor simulation inputs.

Gas mixture and equilibrium prep

Convert inventory moles into dimensionless composition vectors for Raoult, Dalton, and equilibrium-constant calculations.

What happens if total moles is zero?

Mole fraction divides by total moles, so an all-zero mixture is rejected instead of returning Infinity or NaN.

How do I choose which substance to report?

Index 0 is the first entry, index 1 the second, and so on.

What does it cost?

The browser tool is free and runs locally.

What is the mole fraction of the first component in a 2, 3 and 5 mole mixture?

It is 0.2, because 2 of the 10 moles in total belong to it. The other two components take 3 and 5 tenths, and the three fractions add up to one.

Can I type the masses of the components instead?

No. The calculator works from moles only and has no table of molar masses. Divide each mass by its molar mass first, then enter the resulting moles for each component.

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.

POSThttps://api.kit.forhosting.com/chem/mole-fraction

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.

curl -X POST https://api.kit.forhosting.com/chem/mole-fraction \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"moles":[2,3,5],"component_index":0}'
{
  "moles": [
    2,
    3,
    5
  ],
  "component_index": 0
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "chem.mole_fraction",
  "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.

Per request$0.002

Published price — no tokens, no invented credits. A failed task is never charged.

HTTPCodeMeaning
401unauthorizedMissing or invalid API key.
402insufficient_balanceYour balance doesn't cover the task price.
404unknown_typeThat task type doesn't exist.
429rate_limitedToo many requests. Use the webhook instead of polling.

For a multi-component system the mole fraction of substance i is the amount of that substance in moles divided by the total amount of all substances present: x_i equals n_i over n_total.

How mole fraction is defined and why total moles matter

Each individual amount must be finite and non-negative: zero moles for one species is a legitimate limit that yields mole fraction zero for that index, while a negative amount is rejected as non-physical. Callers who only know grams of each substance must convert to moles with molar masses before calling, because this landing intentionally stays on the pure mole-fraction definition without embedding a compound library. Start from the formal definition used in general and physical chemistry textbooks: the mole fraction x_i of component i is the quotient of the amount of that component n_i measured in moles and the total amount of substance in the mixture n_total, where n_total is the sum of n_j over every component j. Write x_i equals n_i divided by n_total and treat the result as a pure number between zero and one inclusive when inputs are physical. The total must be strictly positive; if every component has zero moles the ratio is undefined, and the capability fails with a clear invalid_input message rather than returning Infinity or NaN. Unlike mass fraction, mole fraction weights species by particle count, which is why vapour-liquid equilibrium, chemical potential, and ideal-gas partial-pressure formulas use x_i or y_i rather than weight percent. This capability evaluates the closed form in deterministic floating-point arithmetic: no random seeds, no wall-clock timestamps, no network calls, and no model drift, so identical inputs always produce identical JSON. It does not compute molality, molarity, mass percent, or partial pressures from mole fraction alone; those are separate search intents with their own landings when product coverage grows.

What you send and what you get back

Classic textbook checks include moles two three five with index zero giving mole fraction zero point two, a binary mix of one and one with either index giving one half, and a pure substance array with a single positive entry giving mole fraction one. Keep the component order stable across multi-step pipelines so index zero always means the same species your report labels. Send two required fields: moles, a non-empty array of finite non-negative numbers giving the amount of each mixture component in moles in a fixed order, and component_index, a zero-based integer selecting which substance mole fraction to report as the primary answer. moles must have at least one entry and at most one thousand; empty arrays, non-numeric strings, NaN, Infinity, and negative entries fail with invalid_input and are not charged. component_index must be an integer in the closed range from zero through moles length minus one; out-of-range indices fail the same way. If the sum of all moles is zero, the request fails because mole fraction divides by that total. On success the response echoes cleaned moles and component_index, provides n_i for the chosen substance and total_moles for the mixture, returns mole_fraction as the primary dimensionless result, includes all_mole_fractions as the full composition vector in the same order as moles, sets component_count, attaches a units hint object, sets method to mole_fraction_from_component_moles, and formula to x_i equals n_i over n_total so homework write-ups can cite the same expression. Pricing for successful API calls is the published base of $0.002 per item; validation failures do not consume prepaid balance.

Where mole fraction calculators show up in real work

Because this capability is a pure parse engine, API pricing is the published base of $0.002 per successful item and failed validation does not consume balance.

Homework and lab answer keys

Compute x_i = n_i / n_total from an ordered list of component moles so students and auto-graders share one closed-form ground truth.

What is mole fraction?

Mole fraction x_i is the amount of component i in moles divided by the total moles of all components: x_i = n_i / n_total. It is dimensionless and, when every species is counted, the mole fractions sum to one.

Can I get mole fractions for every component?

Yes. The response includes all_mole_fractions in the same order as moles, plus mole_fraction for the chosen component_index.

Read the full KIT documentation →