Snap To Grid
snap_to_gridSnap schematic elements to the nearest grid point to fix off-grid connectivity that causes ERC errors in KiCAD, modifying the .kicad_sch file in place.
Instructions
Snap schematic element coordinates to the nearest grid point. KiCAD uses exact integer matching for connectivity, so off-grid coordinates cause wires that look connected to fail ERC checks. Modifies the .kicad_sch file in place. Does not require the KiCAD UI to be running.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"schematicPath": "<schematicPath>"
},
"name": "snap_to_grid"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| elements | No | Element types to snap (default: ["wires", "junctions", "labels"]). "components" is opt-in — moving a component without re-routing wires creates new mismatches. | |
| gridSize | No | Grid spacing in mm (default: 1.27 mm = 50 mil, the KiCad connection grid; do NOT use 2.54 — snapping to a 100 mil grid moves pins off their 50 mil positions and breaks connectivity) | |
| schematicPath | Yes | Path to the .kicad_sch schematic file |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |