Formal charge calculator
Find the formal charge of any atom in a Lewis structure from three counts: nitrogen in ammonium, with 5 valence electrons, no lone-pair electrons and 8 bonding electrons, comes out at plus one. Each substitution is shown. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
Worked example
- Valence electrons
- 4
- Number of non-bonding
- 0
- Number of bonding
- 8
- Formal charge
- 0
- Charge label
- 0
A formal charge calculator turns three electron counts from a Lewis structure into the single integer chemists use to assign charge to each atom without a full quantum calculation. Enter the free-atom valence electron count V, the non-bonding lone-pair electron count N on that atom, and the bonding shared electron count B around it; the tool returns formal charge FC equals V minus N minus B over two, a readable charge label, step-by-step substitution, and a short English summary of whether the atom is neutral, positive, or negative. Homework checks, resonance preference, and automated grading all need that same FC assignment from textbook Lewis dots.
What formal charge means in a Lewis structure
Formal charge is a bookkeeping tool for Lewis structures, not a measured partial charge from spectroscopy.
For any atom in a drawn structure you count three integers: V, the number of valence electrons the free atom would have in its ground-state configuration (for main-group elements this is usually the group number in the old A/B or modern IUPAC numbering); N, the number of non-bonding electrons drawn as lone pairs on that atom—count electrons, so one lone pair is two, not one; and B, the total number of bonding electrons shared in all bonds to neighbors—each single bond contributes two electrons, a double bond four, a triple bond six.
The closed formula is formal charge equals V minus N minus one half of B. When FC is zero the atom is formally neutral in that structure; when FC is positive the atom is electron-deficient relative to the free atom; when FC is negative it has gained electron bookkeeping density. Teachers use formal charges to rank resonance contributors: structures with smaller absolute formal charges and with negative charge on more electronegative atoms are preferred.
Students who confuse lone-pair electrons with the number of lone pairs, or who count bonds instead of bonding electrons, get the wrong sign or magnitude; this tool forces the three counts to be explicit so the substitution is transparent. The calculator does not invent a Lewis structure from a molecular formula—you must already know V, N, and B from your drawing or from a problem statement.
Practical tips, classic examples, and related searches
Classic classroom checks: carbon in methane has V equals four, N equals zero, B equals eight, so FC equals zero; nitrogen in the ammonium ion has V equals five, N equals zero, B equals eight, so FC equals plus one; oxygen in water has V equals six, N equals four, B equals four, so FC equals zero; oxygen in hydroxide has V equals six, N equals six, B equals two, so FC equals minus one.
Always count bonding electrons as two per single bond drawn to the atom, not as the number of lines. Prefer sending numbers rather than pre-formatted strings when you control the client; string numbers are accepted only when they match a strict finite numeric pattern and resolve to integers. Prefer this capability when you already have the three counts and only need the formal charge; if your source is a word problem, extract V, N, and B from the Lewis diagram first.
What you can do with it
Homework checks for Lewis formal charge
Students enter V, N, and B from textbook Lewis structures and compare hand-written formal charges and signs against a deterministic result before submitting.
Resonance ranking pre-checks
Pipelines score candidate Lewis structures by absolute formal charge magnitude after computing FC for each atom from explicit electron counts.
FAQ
What is the formal charge formula?
Formal charge FC = V − N − B/2, where V is free-atom valence electrons, N is lone-pair (non-bonding) electrons on the atom, and B is bonding (shared) electrons around the atom.
Do I count lone pairs or lone-pair electrons?
Count electrons. One lone pair is two electrons for N. If you enter the number of pairs instead of electrons, the formal charge will be wrong.
What happens with a negative electron count?
Electron counts in Lewis bookkeeping must be zero or positive integers.
Is formal charge the same as oxidation number?
No. Formal charge assumes equal sharing of bonding electrons; oxidation numbers assign bonding electrons to the more electronegative atom. Use this tool only for formal charge.
Is the formal charge calculator free?
The browser tool is free and runs locally.
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/formal-charge \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"valence_electrons":4,"lone_pair_electrons":0,"bonding_electrons":8}'const res = await fetch("https://api.kit.forhosting.com/chem/formal-charge", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"valence_electrons": 4,
"lone_pair_electrons": 0,
"bonding_electrons": 8
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/chem/formal-charge",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"valence_electrons": 4,
"lone_pair_electrons": 0,
"bonding_electrons": 8
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/chem/formal-charge", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"valence_electrons":4,"lone_pair_electrons":0,"bonding_electrons":8}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"valence_electrons":4,"lone_pair_electrons":0,"bonding_electrons":8}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/chem/formal-charge", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"valence_electrons": 4,
"lone_pair_electrons": 0,
"bonding_electrons": 8
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "chem.formal_charge",
"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.
Limits
max_abs | 1000000000000 |
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
Negative electron counts are rejected with invalid_input so a typo cannot invent a meaningless negative valence shell.
How to call the API and what comes back
Absolute values must stay within the published limit of one trillion; values must be integers because electron counts are discrete in Lewis theory. Send a JSON body with three required non-negative integers: valence_electrons (aliases valence, V, ve, valence_e), lone_pair_electrons (aliases lone_pairs, lone_pair, nonbonding, non_bonding, nonbonding_electrons, N, L), and bonding_electrons (aliases bonding, shared, shared_electrons, B, bonding_e). Any negative count is rejected with invalid_input and a message that names the offending field—zero is allowed, which covers atoms with no lone pairs or no bonds in edge cases. On success the response echoes rounded valence_electrons, lone_pair_electrons, and bonding_electrons, sets formal_charge to the rounded FC value, formula to the string FC equals V minus N minus B over two, charge_label to a compact display such as zero, plus one, or minus one, message to a short English summary of the sign, and steps to an ordered array of substitution lines you can assert in tests. Failed validation—missing fields, non-finite numbers, non-integers, values outside absolute limits, or negative counts—returns invalid_input and is never charged. Pricing is a flat $0.002 per successful request with unit item and zero marginal unit price.
Practical tips, classic examples, and related searches
Keep counts inside the published absolute range so intermediate arithmetic stays finite on the Worker and in the browser. This landing targets people searching for a formal charge calculator, valence lone pair bonding electrons, or FC equals V minus N minus B over two online; it is not an oxidation-number tool, not a partial-charge quantum calculator, and not a Lewis-structure drawer that invents bonds from a formula. Failed tasks that return invalid_input do not consume prepaid balance, which keeps exploratory scripts cheap when learners deliberately send negative counts. Round-trip checks are easy: recompute V minus N minus B over two by hand and confirm it equals the published formal_charge within the same twelve-decimal rounding, and confirm that charge_label matches the sign of that value.
Integration use cases
Unit tests for chemistry education apps
Generate known-good neutral, positive, and negative formal-charge cases plus deliberate negative-count rejections for coding kata and grading fixtures.