{
  "id": "valence-electrons",
  "version": "d6e5919b3fe3",
  "status": "published",
  "name": "Valence Electrons Calculator",
  "question": "How many valence electrons total?",
  "summary": "Counts the valence electrons of any element from its ground-state electron configuration, or the total valence electrons of a molecule or ion for drawing its Lewis structure.",
  "category": "chemistry",
  "subcategory": "atoms",
  "url": "https://www.acalculator.org/chemistry/valence-electrons-calculator",
  "markdown": "https://www.acalculator.org/chemistry/valence-electrons-calculator.md",
  "kind": "function",
  "method": "Element: main group, the s and p electrons of the outermost shell (n = period); groups 3 to 12, the ns and (n − 1)d electrons; lanthanides and actinides, every electron outside the noble-gas core. Molecule or ion: the sum of each main-group atom’s valence electrons × its count, minus the charge.",
  "assumptions": [
    "Neutral atoms in their ground state: NIST’s configuration for Z up to 108, the Madelung filling order beyond.",
    "Lanthanides are La to Lu (57 to 71) and actinides Ac to Lr (89 to 103), as in OpenStax’s periodic table.",
    "A molecule or ion may hold main-group atoms only (groups 1, 2 and 13 to 18, with hydrogen and helium)."
  ],
  "inputs": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "for": {
        "title": "Count for",
        "description": "One element, or a whole molecule or ion (for a Lewis structure).",
        "type": "string",
        "enum": [
          "element",
          "formula"
        ]
      },
      "z": {
        "title": "Element",
        "description": "The element, by atomic number, symbol and name.",
        "type": "string",
        "enum": [
          "1",
          "2",
          "3",
          "4",
          "5",
          "6",
          "7",
          "8",
          "9",
          "10",
          "11",
          "12",
          "13",
          "14",
          "15",
          "16",
          "17",
          "18",
          "19",
          "20",
          "21",
          "22",
          "23",
          "24",
          "25",
          "26",
          "27",
          "28",
          "29",
          "30",
          "31",
          "32",
          "33",
          "34",
          "35",
          "36",
          "37",
          "38",
          "39",
          "40",
          "41",
          "42",
          "43",
          "44",
          "45",
          "46",
          "47",
          "48",
          "49",
          "50",
          "51",
          "52",
          "53",
          "54",
          "55",
          "56",
          "57",
          "58",
          "59",
          "60",
          "61",
          "62",
          "63",
          "64",
          "65",
          "66",
          "67",
          "68",
          "69",
          "70",
          "71",
          "72",
          "73",
          "74",
          "75",
          "76",
          "77",
          "78",
          "79",
          "80",
          "81",
          "82",
          "83",
          "84",
          "85",
          "86",
          "87",
          "88",
          "89",
          "90",
          "91",
          "92",
          "93",
          "94",
          "95",
          "96",
          "97",
          "98",
          "99",
          "100",
          "101",
          "102",
          "103",
          "104",
          "105",
          "106",
          "107",
          "108",
          "109",
          "110",
          "111",
          "112",
          "113",
          "114",
          "115",
          "116",
          "117",
          "118"
        ]
      },
      "f": {
        "title": "Formula",
        "description": "A molecule or ion of main-group atoms, such as CO2, NH4^+ or SO4^2-.",
        "type": "string",
        "maxLength": 100
      }
    }
  },
  "outputs": {
    "valence": {
      "label": "Valence electrons",
      "description": "The valence electrons of the element, or the total for the molecule or ion.",
      "format": "integer"
    },
    "rule": {
      "label": "Counted as",
      "description": "Which electrons count, by the kind of element, or the sum over the atoms.",
      "format": "text"
    },
    "outer": {
      "label": "Outer-shell s and p electrons",
      "description": "Electrons in the s and p subshells of the shell numbered as the element’s period.",
      "format": "integer"
    },
    "configuration": {
      "label": "Electron configuration",
      "description": "The ground-state configuration in noble-gas notation.",
      "format": "text"
    },
    "subject": {
      "label": "For",
      "description": "The element or the formula.",
      "format": "text"
    },
    "words": {
      "label": "In words",
      "description": "The count with its noun, such as 1 valence electron.",
      "format": "text"
    }
  },
  "defaultAnswer": {
    "inputs": {
      "for": "element",
      "z": "8",
      "f": "CO2"
    },
    "outputs": {
      "valence": 6,
      "rule": "Main-group element: the electrons in its outermost shell, n = 2: 2s² 2p⁴",
      "outer": 6,
      "configuration": "[He] 2s² 2p⁴",
      "subject": "Oxygen (O)",
      "words": "6 valence electrons"
    },
    "text": "Oxygen (O) has 6 valence electrons."
  },
  "examples": [
    {
      "given": {
        "for": "element",
        "z": "8"
      },
      "expect": {
        "valence": 6,
        "configuration": "[He] 2s² 2p⁴"
      },
      "source": "OpenStax, Chemistry 2e, §6.4 Electronic Structure of Atoms (Electron Configurations) (valence electrons), https://openstax.org/books/chemistry-2e/pages/6-4-electronic-structure-of-atoms-electron-configurations: main-group valence electrons are those in the highest n level; hand calculation in content.mdx: 2s² 2p⁴ = 6"
    },
    {
      "given": {
        "for": "element",
        "z": "17"
      },
      "expect": {
        "valence": 7
      },
      "source": "OpenStax, Chemistry 2e, §6.4 Electronic Structure of Atoms (Electron Configurations) (valence electrons), https://openstax.org/books/chemistry-2e/pages/6-4-electronic-structure-of-atoms-electron-configurations: fluorine and chlorine each have seven valence electrons"
    },
    {
      "given": {
        "for": "element",
        "z": "31"
      },
      "expect": {
        "valence": 3,
        "configuration": "[Ar] 3d¹⁰ 4s² 4p¹"
      },
      "source": "OpenStax, Chemistry 2e, §6.4 Electronic Structure of Atoms (Electron Configurations) (valence electrons), https://openstax.org/books/chemistry-2e/pages/6-4-electronic-structure-of-atoms-electron-configurations: gallium, [Ar]4s²3d¹⁰4p¹, has three valence electrons; the filled d subshell is core"
    },
    {
      "given": {
        "for": "element",
        "z": "26"
      },
      "expect": {
        "valence": 8,
        "outer": 2
      },
      "source": "OpenStax, Chemistry 2e, §6.4 Electronic Structure of Atoms (Electron Configurations) (valence electrons), https://openstax.org/books/chemistry-2e/pages/6-4-electronic-structure-of-atoms-electron-configurations: transition elements count the ns and (n − 1)d electrons; hand calculation in content.mdx: 4s² + 3d⁶ = 8"
    },
    {
      "given": {
        "for": "formula",
        "f": "SiH4"
      },
      "expect": {
        "valence": 8,
        "rule": "4 (Si) + 4 × 1 (H) = 8"
      },
      "source": "OpenStax, Chemistry 2e, §7.3 Lewis Symbols and Structures (total valence electrons; subtract one per positive charge, add one per negative), https://openstax.org/books/chemistry-2e/pages/7-3-lewis-symbols-and-structures: SiH₄, 4 + 4(1) = 8 valence electrons"
    },
    {
      "given": {
        "for": "formula",
        "f": "CHO2^-"
      },
      "expect": {
        "valence": 18
      },
      "source": "OpenStax, Chemistry 2e, §7.3 Lewis Symbols and Structures (total valence electrons; subtract one per positive charge, add one per negative), https://openstax.org/books/chemistry-2e/pages/7-3-lewis-symbols-and-structures: CHO₂⁻, 4 + 1 + 2(6) + 1 = 18"
    },
    {
      "given": {
        "for": "formula",
        "f": "NO^+"
      },
      "expect": {
        "valence": 10,
        "rule": "5 (N) + 6 (O) − 1 (charge +1) = 10"
      },
      "source": "OpenStax, Chemistry 2e, §7.3 Lewis Symbols and Structures (total valence electrons; subtract one per positive charge, add one per negative), https://openstax.org/books/chemistry-2e/pages/7-3-lewis-symbols-and-structures: NO⁺, 5 + 6 − 1 = 10"
    },
    {
      "given": {
        "for": "formula",
        "f": "XeF6"
      },
      "expect": {
        "valence": 50
      },
      "source": "OpenStax, Chemistry 2e, §7.3 Lewis Symbols and Structures (total valence electrons; subtract one per positive charge, add one per negative), https://openstax.org/books/chemistry-2e/pages/7-3-lewis-symbols-and-structures, Example 7.5: XeF₆, 8 + 6(7) = 50"
    }
  ],
  "sources": [
    "OpenStax, Chemistry 2e, §6.4 Electronic Structure of Atoms (Electron Configurations): valence electrons are those in the highest n shell for main-group elements, completely filled d orbitals count as core (gallium has three valence electrons), transition elements count the ns and (n − 1)d electrons, inner transition elements the (n − 2)f, (n − 1)d and ns, and fluorine and chlorine each have seven. https://openstax.org/books/chemistry-2e/pages/6-4-electronic-structure-of-atoms-electron-configurations (retrieved 2026-10-19)",
    "OpenStax, Chemistry 2e, §7.3 Lewis Symbols and Structures: total valence electrons for a Lewis structure, one less per positive charge and one more per negative charge, with SiH₄ 8, CHO₂⁻ 18, NO⁺ 10, OF₂ 20, HCN 10 and XeF₆ 50. https://openstax.org/books/chemistry-2e/pages/7-3-lewis-symbols-and-structures (retrieved 2026-10-19)",
    "OpenStax, Chemistry 2e, §2.5 The Periodic Table: transition metals in groups 3 to 12, lanthanides 57 to 71 and actinides 89 to 103. https://openstax.org/books/chemistry-2e/pages/2-5-the-periodic-table (retrieved 2026-10-19)",
    "NIST Standard Reference Database 111, Ground Levels and Ionization Energies for the Neutral Atoms: ground-state configurations for Z = 1 to 108, in its HTML table in the NIST Atomic Spectra Database. https://www.nist.gov/pml/ground-levels-and-ionization-energies-neutral-atoms (retrieved 2026-10-19)"
  ],
  "related": [
    "electron-configuration",
    "formal-charge",
    "effective-nuclear-charge",
    "protons-neutrons-electrons"
  ],
  "changelog": []
}
