Hey Everyone,
I got tired of manually typing out net labels in KiCad one by one, so I threw together a little Python script—labelgen.py—that automates the whole process from a simple CSV. It pops up a quick dialog (backs up your schematic, lets you pick mil/mm and local/global), then reads your “Label” column, uppercases everything, and drops each net label at the top-left outside the title block. No virtualenv wrestling— it even auto-installs its one dependency.
Figured it might save someone else some time, so I’m sharing it here. Feel free to grab it, try it out, and let me know if you find any quirks or improvements!
labelgen.py – KiCad Net Label Inserter
A lightweight Python utility to insert local or global net labels into a KiCad schematic (.kicad_sch
) from a CSV file.
Features
- Interactive GUI for configuration and file selection (Windows/macOS).
- Imperial (mil) and Metric (mm) unit support—default is mil.
- Local or Global net label option via checkbox—default is local.
- Automatic backup of the schematic (
.bak
saved alongside original). - Uppercases all labels for consistency.
- Direct file editing using
kicad-skip
—no external APIs.
Prerequisites
- Python 3.7+ on your
PATH
. - pip (comes with most Python installs).
- tkinter (standard library GUI toolkit).
- kicad-skip (auto‑installed if missing).
Installation
-
Place
labelgen.py
in a folder outside your KiCad project root. -
(Optional) Make it executable:
chmod +x labelgen.py
Usage
-
Run the script:
python labelgen.py
-
A Disclaimer dialog appears:
- Edits the native
.kicad_sch
file in place. - Creates a backup
*.bak
next to the original. - Recommended to run outside the project root.
- Labels are placed outside the titleblock at top-left center.
- Click Yes to continue, No/Close to cancel.
- Edits the native
-
The Settings & Files dialog appears:
- Defaults: mil units, local labels.
- Check Use metric units (mm) to switch to millimeters.
- Check Use global labels for global net labels.
- Browse and select your
.kicad_sch
file. - Browse and select your
.csv
file (must contain aLabel
column). - Click OK to start insertion.
-
After processing, a summary shows how many labels were inserted.
CSV Format
Your CSV must include a header named Label
(case-insensitive). All other columns are ignored. Example data:
Pin Number,Pin Name,Label
PB0,PB0,RGMII_RXD2
PB1,PB1,RGMII_RXD3
PB3,PB3,RGMII_RXCTL
PB4,PB4,RGMII_TXD2
PB5,PB5,RGMII_TXD3
PB6,PB6,RGMII_GTXCLK
PB7,PB7,RGMII_GTXEN
Each entry in the Label column is automatically converted to uppercase and inserted as a net label in the schematic. For example, a CSV value of rgmii_rxd2
becomes RGMII_RXD2
in the schematic.
Contributing
Contributions welcome! To contribute:
- Fork this repository.
- Create a branch:
git checkout -b feature/YourFeature
. - Implement your changes and commit:
git commit -m "Add feature X"
. - Push to your fork:
git push origin feature/YourFeature
. - Open a Pull Request describing your enhancement.
Please follow the existing style and update this README for any user-facing changes.
License
This project is licensed under the MIT License. See LICENSE for details.
Changelog
v1.1 (2025‑05‑23)
- Added global‑label support (checkbox now inserts only global labels when selected).
- Removed custom X/Y inputs; labels start at –10 mm, –10 mm by default.
- Default pitch set to 100 mil (imperial) or 2 mm (metric). Pitch remains editable.
- File‑path fields now show selected schematic/CSV immediately.
- README updated with clarified defaults and CSV example.
v1.0 (2025‑02‑05)
- Initial public release with local net‑label insertion from CSV.
Generated by Prism Enterprise LLC