Lewis Structure Generator
Generate Lewis structures, count valence electrons, calculate formal charges, and learn bonding with step-by-step visuals.
Background
Lewis structures show how valence electrons are arranged as bonds and lone pairs. This generator helps students build structures, check octets, compare formal charges, and recognize resonance for common general chemistry molecules and polyatomic ions.
How to use this generator
- Enter a formula such as CO2, NH3, NO3-, or SO4^2-.
- Use auto charge detection or choose the charge manually.
- Click Generate to see valence electron count, bonding layout, lone pairs, formal charges, and octet notes.
- Use resonance mode for ions and molecules with multiple valid electron arrangements.
How this calculator works
The generator first parses the formula and charge, then counts total valence electrons. For supported Gen Chem examples, it uses a curated preset so the structure, lone pairs, formal charges, expanded-octet notes, and resonance contributors are shown with higher confidence. For other simple formulas, it builds a guided skeleton by choosing a central atom, connecting terminal atoms, distributing lone pairs, and asking you to verify octets and formal charges.
The result area is designed for learning: it shows the structure confidence badge, the reason for the central atom choice, bracketed ion drawings, resonance previews when relevant, an octet/duet status table, and copyable summaries for notes.
Formula & Rules Used
Total valence electrons: add valence electrons for each atom, add electrons for negative charge, subtract electrons for positive charge.
Formal charge: FC = valence − nonbonding electrons − bond order sum.
Octet rule: second-row atoms usually prefer 8 electrons; hydrogen prefers 2 electrons.
Resonance: when multiple valid structures differ only in electron placement, the real structure is represented by resonance contributors.
Example Problems & Step-by-Step Solutions
Example 1: CO2
CO2 has 16 valence electrons. Carbon goes in the center, and two C=O double bonds give every atom an octet with formal charges of 0.
Example 2: NH3
NH3 has 8 valence electrons. Nitrogen forms three N–H bonds and keeps one lone pair.
Example 3: NO3-
NO3- has 24 valence electrons. One N=O bond and two N–O bonds can be drawn in three equivalent resonance positions.
Frequently Asked Questions
What is a Lewis structure?
A Lewis structure is a diagram that shows valence electrons as bonds and lone pairs around atoms.
How do I choose the central atom?
Hydrogen is never central. In many simple molecules, the least electronegative non-hydrogen atom is central.
What is formal charge?
Formal charge estimates how electrons are assigned in a Lewis structure and helps compare possible structures.
Why do some structures have resonance?
Resonance occurs when the same atoms can be connected with equivalent electron arrangements that differ only in bond and lone-pair placement.