KiCad BOM generation

BOM (Bill Of Materials) generation is an important and usually cumbersome part of doing electronics.  KiCad has two ways to generate a BOM: from the schematic and from the layout.

Layout based

In pcbnew select from the menu: File -> Fabrication outputs -> BOM file.

This generates a simple CSV (Comma Separated Value)  file with the components grouped by type and value.

"Id";"Designator";"Package";"Quantity";"Designation";"Supplier and ref";


While useful for simple boards and experiments, in practice you usually want more detail e.g. capacitor voltage in the BOM, as explained nicely in this article from Spark.

Schematics based

KiCad also allows generating a BOM from the schematic. This works by it generating an XML exporting all the data fields for all used components and post-processing this XML with a script. This is nice as it allows to document everything in one place: the schematic.


example component with Fields providing good detail


The biggest disadvantage is that currently it seems to be impossible to save these extra fields as part of a component meaning it involves manual entering for each schematic. Automating this in some way would be nice.

The actual generation of the BOM is done with the menu: Tools -> Generate Bill Of Materials

This gives the following screen:



This may seem a bit daunting but it is actually quite simple. What KiCad does is just generate an XML file with all the components with all the fields. Each plugin is just a script that is passed that XML file as an argument and the output is the resulting BOM.

An example XML fragment:

<comp ref="C12">
    <field name="Voltage">10V</field>
    <field name="Package">0402</field>
    <field name="Identifier">capacitor</field>
    <field name="Tolerance">X5R +-10%</field>
  <libsource lib="passive" part="C"/>
  <sheetpath names="/" tstamps="/"/>


This example python code generates a BOM from the XML, assuming a bunch of standard fields and allowing for extra fields, groups by Identifier and Value.

It uses the beautifulsoup python library for easy parsing of the XML.

P.S.: for the language purists out there: yes, this code is very inefficient (quadratic complexity) but it still runs in milliseconds on a modern computer so it doesn’t matter 😉


It is possible to generate a nice and detailed BOM from KiCad but there is still work making it more automated.