KiPart
Generate multi-unit schematic symbols for KiCad from a CSV, text,
Excel, or SPD file.
Features
kipart generates schematic part libraries for KiCad from CSV or Excel files.
- Converts one or more lists of pins in a file into a library of
multi-unit schematic part symbols.
- Each row of the file lists the number, name, type, style, and
unit of a pin along with what side of the symbol to place the pin on.
- Has several command-line options for controlling the arrangement and
order of the pins.
- Pins with the same name (e.g., GND) can be placed at the
same location so they can all be tied to a net with a single
connection.
- Also includes
kilib2csv for converting existing schematic part libraries
into CSV files suitable for input to KiPart.
- Also includes
kilib2spd for converting existing schematic part libraries
into SPD (Shorthand Part Description) files, so a library can be maintained
in a compact, human-friendly format.
- Also includes
kilib2jpd for converting existing schematic part libraries
into JPD (JSON Part Description) files, so a library can be maintained in
an AI-friendly format.
- Also includes
spd2csv for converting Shorthand Part Description (SPD) files
to CSV format which can then be turned into schematic part libraries.
- Also includes
spd2jpd and jpd2spd for converting between SPD and JPD files.
- Also includes
cmpparts for comparing the parts of two or more libraries
and flagging discrepancies.
- Also includes
kipart-mcp, an MCP server that puts all of the above within
reach of an AI agent, taking part descriptions as text as well as files so a
symbol can be built without anything touching disk.
Example Use Case
From a user:
I had a very complex library for a microprocessor that I needed to
refactor--- I needed to reorder hundreds of pins in a sane human-usable
format. I thought I was going to have do it by hand in KiCAD's
graphical symbol editor. I tried that, got very frustrated with all the
clicking and dragging.
So I then:
- searched and found this tool,
- used
kilib2csv to export my KiCAD lib to CSV,
- imported the CSV in a spreadsheet program
- edited the spreadsheet (mainly sorting the pins by function using
the spreadsheet's
sort() function),
- exported the spreadsheet back to CSV,
- used
kipart to export back to KiCAD.
Boom! Usable part in minutes.
Installation
Simple enough:
pip install kipart
This will install eight part-conversion command-line utilities:
kipart: The main utility for generating schematic symbols from rows of pin data
stored in CSV or Excel files.
spd2csv: A utility for converting SPD (Shorthand Part Description)
files to CSV format for use with KiPart.
kilib2csv: A utility for converting existing KiCad libraries into
CSV files. This is useful for converting existing libraries into a format that
can be used with KiPart.
kilib2spd: A utility for converting existing KiCad libraries into
SPD files, which is the reverse of the spd2csv + kipart pipeline.
spd2jpd, jpd2spd, and kilib2jpd: Utilities for converting SPD files and
KiCad libraries to and from JPD (JSON Part Description) files, for when a
part is easier to handle as JSON than as text.
cmpparts: A utility for comparing the parts of two or more libraries and
reporting what differs between them.
All eight are also reachable by an AI agent through the MCP server, which is
installed as a ninth command, kipart-mcp. It needs FastMCP, which doesn't come
with KiPart, so install the extra before running it:
pip install "kipart[mcp]"
See Using KiPart from an AI agent below.
How the utilities fit together
A part reaches a KiCad .kicad_sym library along one path: a description consisting of
rows of CSV or Excel data is converted by kipart into a symbol library.
Part descriptions can also be stored in JPD or SPD formats which are convertible
to CSV via the jpd2spd and spd2csv utilities.
A KiCad library can be converted back to each of these formats using one of the
kilib2* utilities.
cmpparts sits off to the side, comparing the parts held in any of the
.kicad_sym, .spd, or .jpd files.
flowchart LR
JPD["JPD file<br/>(.jpd)"]
SPD["SPD file<br/>(.spd)"]
CSV["CSV / Excel<br/>(.csv .xlsx .xls)"]
LIB["KiCad library<br/>(.kicad_sym)"]
JPD -->|jpd2spd| SPD
SPD -->|spd2jpd| JPD
SPD -->|spd2csv| CSV
CSV -->|kipart| LIB
LIB -->|kilib2csv| CSV
LIB -->|kilib2spd| SPD
LIB -->|kilib2jpd| JPD
CMP{{"cmpparts<br/>(compare parts)"}}
JPD -.-> CMP
SPD -.-> CMP
LIB -.-> CMP
Usage
KiPart
KiPart is mainly intended to be used as a script:
usage: kipart [-h] [-o OUTPUT] [-w] [-m] [-1] [-s {row,num,name}] [-r] [--ccw] [--scrunch] [--side {left,right,top,bottom}] [--type TYPE] [--style STYLE] [--push PUSH] [-a ALT_DELIMITER] [-b]
[--bundle-style {none,count,range}] [--hide-pin-num] [-j {left,center,right}] [-v]
[input_files ...]
Convert CSV or Excel files into KiCad symbol libraries
positional arguments:
input_files Input symbol pin data CSV or Excel files (.csv, .xlsx, .xls). If no files are given, reads from stdin.
options:
-h, --help show this help message and exit
-o, --output OUTPUT Output KiCad symbol library file (.kicad_sym)
-w, --overwrite Allow overwriting of an existing symbol library
-m, --merge Merge symbols into an existing library rather than overwriting completely
-1, --one-symbol Ignore blank lines rather than starting a new symbol
-s, --sort {row,num,name}
Sort the part pins by their entry order in the CSV file (row), their pin number (num), or their pin name (name)
-r, --reverse Sort pins in reverse order
--ccw Arrange pins counter-clockwise around the symbol
--scrunch Compress symbol pins on the left/right sides underneath the top/bottom sides
--side {left,right,top,bottom}
Default side for pins without a side specifier
--type TYPE Default type for pins without a type specifier (e.g., input, output, bidirectional, passive)
--style STYLE Default style for pins without a style specifier (e.g., line, inverted, clock)
--push PUSH Position of pin groups on each side (0.0=start, 0.5=centered, 1.0=end)
-a, --alt-delimiter ALT_DELIMITER
Delimiter character for splitting pin names into alternatives
-b, --bundle Bundle identically-named power or ground input pins into single schematic pins
--bundle-style {none,count,range}
When bundling pins, selects what is appended to the net name
--hide-pin-num Hide pin numbers
-j, --justify {left,center,right}
Sets the justification on visible properties
-v, --version show program's version number and exit
The input to kipart is one or more CSV or Excel files.
These contain the following items:
The part name or number stands alone in the first column of a row.
Part properties are listed on the following rows, one property per row and
two columns to a row: the property name with a trailing colon in the first
column, its value in the second (Reference:,U). A property written into a
single cell is not read as a property. The standard properties are:
Reference: The reference designator such as U.
Value: The part value (often the same as the name).
Footprint: The part's package type (e.g., QFP, BGA, etc.).
Datasheet: A URL to the part's datasheet.
Description: A description of the part.
Keywords: Keywords for searching for the part.
Filters: The footprint filters for the part.
Locked: I have no idea what this does...
You can also list part properties with arbitrary names of your own choosing.
After the properties, the next row contains the column headers. The required
headers are Pin and Name. Optional columns are Unit,
Side, Type, Style, and Hidden. These can be placed
in any order and in any column.
Immediately after the column headers, each succeeding row contains the
following data for one of the part's pins: the pin number, name,
unit identifier (if the schematic symbol will have multiple units),
pin type and style. Each of these items should be entered in the
same column as the corresponding header.
Pin numbers can be either numeric (e.g., 69) if the part is
a DIP or QFP, or they can be alphanumeric (e.g., C10) for
BGAs or CSPs. Using a * character instead
of a pin number creates non-existent "gap"
pins that can be used to visually separate the pins into groups.
(This only works when the -s row sorting option is selected.)
Pin names can be any combination of letters, numbers and special
characters (except a comma). If the pin name contains one or more
delimiter characters specified with the -a option, then the name
will be split at each delimiter and the resulting substrings will
be entered as alternate pin functions.
The unit identifier can be blank or any combination of letters,
numbers and special characters (except a comma). A separate unit
will be generated in the schematic symbol for each distinct unit
identifier.
The side column specifies the side of the symbol the pin will be placed on.
The allowable values are:
- left
- right
- top
- bottom
The type column specifies the electrical type of the pin.
The allowable values are:
- input, inp, in, clk
- output, outp, out
- bidirectional, bidir, bi, inout, io, iop
- tri_state, tri-state, tristate, tri
- passive, pass
- free
- unspecified, un, analog
- power_in, pwr_in, pwrin, power, pwr, ground, gnd
- power_out, pwr_out, pwrout, pwr_o
- open_collector, opencollector, open_coll, opencoll, oc
- open_emitter, openemitter, open_emit, openemit, oe
- no_connect, noconnect, no_conn, noconn, nc
The style column specifies the graphic representation of the pin.
The allowable pin styles are:
- line, <blank>
- inverted, inv, ~, #
- clock, clk, rising_clk
- inverted_clock, inv_clk, clk_b, clk_n, ~clk, #clk
- input_low, inp_low, in_lw, in_b, in_n, ~in, #in
- clock_low, clk_low, clk_lw
- output_low, outp_low, out_lw, out_b, out_n, ~out, #out
- edge_clock_high
- non_logic, nl, analog
The hidden column specifies whether the pin is invisible.
This can be one of 'y', 'yes', 't', 'true', or
'1' to make it invisible, anything else makes it visible.
A blank row ends the list of pins for the part.
Multiple parts (each consisting of a name, properties, column header
and pin data rows) separated by blank lines are allowed in a single CSV file.
Each part will become a separate symbol in the KiCad library.
The -s option specifies the pin order on each side of the symbol:
-s row places the pins in the order they were entered into the
file.
-s name places the pins in increasing order of their names.
-s num places the pins in increasing order of their pin numbers
and arranged in a counter-clockwise fashion around the symbol
starting from the upper-left corner.
The --reverse option reverses the sort order for the pins.
The --ccw option arranges the pins running counter-clockwise
around the symbol starting from the upper-left corner. If this
option is not enabled, the pins on the left/right sides will run from
top to bottom and the pins on the top/bottom sides will run from
left to right.
The --scrunch option will compress a three- or four-sided schematic
symbol by moving the left and right columns of pins closer together so
that their pin labels are shadowed by the pins on the top and bottom
rows.
The --side, --type, and --style options set the default
side, I/O type, and graphic style for pins that don't have these
specified in the CSV file.
The --push option is used to set the position of the pins on each side of
the schematic symbol box. A value of 0.0 pushes them to the upper-most
or left-most position on the left/right or top/bottom sides. A value of
1.0 pushes them to the bottom-most or right-most position on the
left/right or top/bottom sides. A value of 0.5 (the default) centers
them.
Specifying the -b option will place multiple power input pins with the identical
names at the same location such that they can all attach to the same net
with a single connection. This is helpful for handling the multiple VCC and
GND pins found on many high pin-count devices.
The -a option specifies a delimiter for splitting pin names
into alternates. This is useful for parts with pins having multiple
functions. For example, -a / will split the pin name IO1/SDA/MOSI into
a pin named IO1 with two alternate names of SDA and MOSI.
In this case, the alternate pins will have different names but
the electrical types and styles will be the same.
If alternate pins with different types and styles are needed,
just create one or more rows with the same data as the primary pin
but change the name, type, and style as needed.
The -w option is used to overwrite an existing library with any new
parts from the file. The old contents of the library are lost.
The -m option is used to merge parts into an existing library. If a part
with the same name already exists, the new part will only overwrite it
if the -w flag is also used. Any existing parts in the library that
are not overwritten are retained.
The --hide-pin-num option is used to hide pin numbers.
Examples
KiPart can process one or more input files. The simplest case is
generating a symbol library from a single CSV file. The following
command will process the file.csv file and place the symbols in
file.kicad_sym:
kipart file.csv
This also works with multiple input files with a separate library
created for each CSV file:
kipart file1.csv file2.csv # Creates file1.kicad_sym and file2.kicad_sym.
Symbols from multiple CSV files can be placed into a single library
using the -o option: