Skip to content
Simurq Labs

Learn

How do you export Gerbers, drill, BOM and CPL files from KiCad?

By Semih Özbir, Electrical and Electronics Engineer

Published · Last reviewed

In this guide · 9

In KiCad's PCB editor, File → Fabrication Outputs exports them: the Gerbers through the Plot dialog, then the drill files and the pick-and-place (CPL) file. The BOM comes from the schematic editor's Tools menu. A two-layer board goes to a fab as seven to nine Gerbers and a drill file; an assembler takes the BOM and the CPL.

How to export them in KiCad 10, step by step

KiCad's getting-started guide and its PCB editor manual give the steps:

  1. Run DRC, with the zones refilled. The files are a snapshot of the board as it stands.
  2. Gerbers: File → Fabrication Outputs → Gerbers (.gbr)…, or File → Plot…, opens the Plot dialog. Choose an output folder, tick the copper, Edge.Cuts, mask and silkscreen layers, and the paste layers if a stencil will be made, then click Plot.
  3. Drill files: in the same dialog, Generate Drill Files…, then Generate Drill File. The one choice it asks is below.
  4. Pick-and-place (CPL): File → Fabrication Outputs → Component Placement (.pos, .gbr)…, as CSV, in the units your assembler reads, with both sides in one file if it takes one.
  5. BOM: in the schematic editor, Tools → Generate Bill of Materials…, then Export. The PCB editor's own Bill of Materials… is, its manual says, kept for legacy reasons and not recommended.

Here is the package file by file, as a PCB Agent job delivers it, with the KiCad settings behind each file.

The files, and who needs which

Three readers, three sets of files:

  • The fab makes the bare board. It needs the Gerbers, one file a layer, the drill file, and the Gerber job file that says what the others are.
  • The assembler places the parts. It needs the bill of materials and the placement file.
  • You need the KiCad project, to open and change, and the reports that say what was checked.

A PCB Agent package holds ten files. The Gerbers, the drill file and the job file come in one zip. The others are the placement file and the BOM workbook; a check report that lists every other file's SHA-256, and the board review; the logo the reports open with; and the KiCad board, schematic and netlist, with the whole project zipped.

File tree of the ten files a PCB Agent job delivers. One zip for the fab holds nine Gerbers, F.Cu to Edge.Cuts, the drill file and board-job.gbrjob. The assembler takes the placement file and BOM workbook. You get the reports, the logo and the KiCad board, schematic, netlist and zipped project.

The ten files of a PCB Agent package and who needs each, with the Gerber layers the KiCad 10.0 documentation lists for a fab.

Gerbers and drill out of KiCad: the layers and the settings

KiCad's getting-started guide says Gerber is the usual format for a fab, and its default settings are fine. JLCPCB's KiCad guide counts seven files for a bare two-layer board, and nine with the paste layers for assembly.

With no window, one command plots them:

  • kicad-cli pcb export gerbers --layers followed by the nine layers: F.Cu, B.Cu, F.Paste, B.Paste, F.Silkscreen, B.Silkscreen, F.Mask, B.Mask and Edge.Cuts. Without --layers it plots every enabled layer, the fabrication and courtyard drawings included, which a fab has no use for.
  • Each file says what it is. KiCad writes Gerber X2 attributes, so the top copper opens with %TF.FileFunction,Copper,L1,Top*%. Ucamco, which keeps the format, puts it plainly: "Gerber X2 is both backward and forward compatible." KiCad's manual still warns that older software at some fabs may not accept X2, so it can be turned off.
  • The units are millimetres, six decimals in the file's own format, so a coordinate is written to a millionth of a millimetre.
  • The job file, board-job.gbrjob, names each Gerber's layer and states the board: its layers, its thickness and its narrowest track. That track can be narrower than the board's usual width, where the autorouter narrowed a segment to fit, as our article on Freerouting explains.

The drill file needs one choice. KiCad's dialog writes plated and non-plated holes to two files by default, and its manual says to merge them only when the fab asks. JLCPCB's KiCad guide asks for the two. The command line merges them unless it is given --excellon-separate-th. Our package's drill file is that merged one, today. It is Excellon, in millimetres, with a tool for each hole size: 0.3 mm for every via, one for each size of through-hole pin, and 3.2 mm for the mounting holes, made for an M3 screw and marked non-plated.

The same bytes on every run

KiCad writes the moment of export into each Gerber twice, once as an attribute and once as a comment. It writes it into the drill file and the job file too. Export the same board twice and every file differs, though nothing on the board did.

We put a fixed instant in its place, 1970-01-01T00:00:00+00:00, and zip the files with sorted names and fixed dates. The same board then gives the same zip, byte for byte, and its SHA-256 in the check report names it. When a file you downloaded matches that hash, it is the file the checks ran on.

The placement file: columns, units, origin, and why a part turns

The placement file is the pick-and-place (CPL) file assemblers ask for. With no window, KiCad writes it through kicad-cli pcb export pos: here as CSV, in millimetres, both sides in one file. Its columns are Ref, Val, Package, PosX, PosY, Rot and Side. Our package rewrites it in the columns assembly services read: Designator, Mid X, Mid Y, Layer and Rotation. Each row gives:

  • the designator, such as U1;
  • the part's position as X and Y, in millimetres to four decimals with the unit written after them, such as 12.5000mm;
  • its side, Top or Bottom;
  • its rotation in degrees, from 0 up to 360.

The coordinates are each part's position as KiCad gives it, in KiCad's own frame, the same as the Gerbers'. Neither file uses the drill and place origin KiCad can set, and Y points up, so a board drawn below KiCad's origin has negative Y values.

The rotation is the one to check. JLCPCB's assembly FAQ explains why a part can show turned in its preview. Your library's 0° may not be its library's, though both count the same way round. A 0° should match how the part sits in its tape, and two parts in one package can sit differently. You can fix the rotation in the file, or leave it to its engineers, who correct it from the silkscreen. Where the silkscreen and the file disagree, it places by the silkscreen. A part in a package that FAQ shows, such as a SOT-23-5 regulator, is worth a look in the preview before the order.

The BOM for assembly

Assemblers name the columns they read. JLCPCB's BOM page asks for Comment, Designator and Footprint, in CSV or a spreadsheet. Its KiCad 10 guide adds its own part number column. It also says KiCad's headers need renaming, Value to Comment and Reference to Designator. Designators become capitals on its line, so two parts must never differ by case alone.

Our BOM workbook has one line for each distinct part, with designators, quantity, value, footprint, maker and part number. Our BOM template article has the columns, the traps and a template to download.

Checking the package before it is sent

A few minutes here save a respin:

  • Open the Gerbers in a viewer, KiCad's GerbView or the fab's own. Check that every layer is there, the outline is closed, and every hole sits on its pad.
  • Check the hashes against the check report, so the files you send are the files that were checked.
  • Read the fab's preview, and for assembly its placement preview, turned parts first.
  • Check the parts against the assembler's stock. Ours were checked at two distributors, not at your assembler.

Our package is checked before you see it: no package leaves a job before DRC passes under the fab's own rules.

The KiCad project as a deliverable

The zipped project holds the board, the schematic and the netlist, with the fab's design rules the board was checked under and its footprint exceptions. Open it in KiCad 10 or later, and KiCad's own DRC checks it as our pipeline did. Change the design, export it again with the settings above, and the files are yours.

Limits

One fab's pages are quoted here, and other fabs name their columns their own way. Everything above is for two-layer boards: each inner layer adds a Gerber. Files that pass their checks are not a board that works: only the built board shows that, and the roadmap says where PCB Agent's own boards stand. If someone else designs your board, custom PCB design says what to ask them for.

Sources

Have a board in mind?

PCB Agent is not open to the public yet. Leave your email, and we'll write when early access starts.