Skip to content

Structure Validation & Cleanup

Molkit includes two related quality tools. Structure validation scans every atom for chemistry mistakes such as too many bonds or an incorrect formal charge, and flags problems directly on the canvas and in a results panel. Structure cleanup nudges atom positions toward standard bond lengths and ideal angles so a hand-drawn molecule looks tidy. Both live in the Structure menu.

Structure validation

What gets checked

Validation runs per atom and reports three kinds of issues:

  • Valence errors and warnings. Each element has a list of accepted valences (C: 4; N: 3, 4, 5; O: 2, 3; S: 2, 4, 6; halogens, common metals, and so on). The total bond order on an atom is compared against that list, with an allowance for charged atoms (a positive charge permits one fewer bond per unit of charge, a negative charge one more). Exceeding the maximum is an error; an unusual but not impossible count is a warning. Pentavalent carbon and hydrogen with more than one bond are always errors.
  • Charge mismatches. If an atom carries a drawn charge that differs from the formal charge computed from its bonds, lone pairs, and element, you get a warning showing both values.
  • Coincident atoms. Two unbonded atoms sitting at the same position (within 1 px) are flagged as errors, since one is hidden behind the other. Bonded pairs at the same spot are skipped because Newman projections place front and back carbons together intentionally.

Where issues appear

  • Canvas indicators. When validation display is on, atoms with issues get a small marker next to the label: a filled red dot with an exclamation mark for errors, an orange ring for warnings. Hover the marker for the message.
  • Validation panel. Choose Structure > Validate Structure… to open a floating panel above the status bar. It lists every issue with the atom label and message, and shows a total count in the header. Click an item to center the canvas on that atom and select it. The panel refreshes live as you edit.

There is no separate status bar badge for validation; the canvas markers and the panel are the two surfaces.

Turning it on and off

Canvas indicators are off by default in every structure preset. Toggle them with Structure > Show Validation Warnings. Opening the validation panel turns the indicators on automatically if they were off. Both commands are also available in the command palette (Ctrl+K).

Validation is display-only. It never blocks drawing or modifies your structure, so you can leave warnings unresolved while working.

Structure cleanup

What it does

Structure > Clean Up Structure normalizes atom positions in four passes, applied to each connected molecule independently:

  1. Bond lengths. Starting from the most-connected atom, bonds that deviate more than 15% from the document’s standard bond length are pulled most of the way toward it.
  2. Straightening. An atom with exactly two bonds that are within 8 degrees of a straight line gets its neighbors aligned onto a single axis.
  3. Angle equalization. Bond angles are adjusted toward the VSEPR ideal for each atom: two-neighbor atoms move toward the ideal angle, and three-neighbor sp2 centers move toward even 120 degree spacing.
  4. Overlap repair. Atoms closer together than about a third of a bond length are pushed apart. Atoms stacked exactly on top of a bonded neighbor are relocated a full bond length away at a fresh angle.

Each pass blends positions partway toward the target rather than snapping them, so one run improves the drawing without distorting it. Run the command again if you want a stronger correction.

What it leaves alone

Cleanup moves atoms only. Arrows, text, shapes, and other annotations stay where they are, and bond orders, charges, and labels are untouched. Isolated single atoms are skipped. If the structure is already within tolerance, the command makes no change at all and adds nothing to the undo history.

Undo

A full cleanup is a single undo step. Press Ctrl+Z once to restore every atom to its previous position.

See also