Skip to main content
KiCad provides a comprehensive command-line interface (CLI) for automating design tasks, generating output files, and running checks without opening the GUI.

Basic Usage

Getting Help

Common Options

Many commands share these options:
  • --help, -h - Show help message and exit
  • --version - Display version information
  • --output <path> - Specify output file or directory
  • --drawing-sheet <file> - Use custom drawing sheet (.wks file)
  • --define-var <VAR=VALUE>, -D - Define variable for text substitution
  • --variant <name> - Specify board variant to use

PCB Commands

pcb export

Export PCB designs to various formats.

Gerber Export

Options:
  • --output <dir>, -o - Output directory
  • --layers <layers> - Comma-separated layer list (e.g., F.Cu,B.Cu,Edge.Cuts)
  • --common-layers <layers> - Layers to include in all outputs
  • --drawing-sheet <file> - Custom drawing sheet
  • --exclude-refdes, --erd - Exclude reference designators
  • --exclude-value, --ev - Exclude component values
  • --include-border-title, --ibt - Include border and title block
  • --no-x2 - Disable Gerber X2 format (use X1)
  • --no-netlist - Disable netlist attributes
  • --subtract-soldermask - Subtract soldermask from silkscreen
  • --disable-aperture-macros - Use simple apertures only
  • --use-drill-file-origin - Use drill/place file origin
  • --precision <digits> - Coordinate precision (4-6, default: 6)
  • --no-protel-ext - Use KiCad file extensions instead of Protel
Example:

Drill File Export

Options:
  • --output <dir>, -o - Output directory
  • --format <format> - Output format: excellon, gerber (default: excellon)
  • --drill-origin <origin> - Origin: absolute, plot (default: absolute)
  • --excellon-zeros <format> - Zero format: decimal, suppressleading, suppresstrailing, keep
  • --excellon-units <units> - Units: mm, in (default: mm)
  • --excellon-oval-format <format> - Oval holes: route, alternate
  • --generate-map - Generate drill map file
  • --map-format <format> - Map format: pdf, gerber, dxf, svg, ps
  • --gerber-precision <digits> - Coordinate precision (5-6, default: 5)
Example:

PDF Export

Options:
  • --output <file>, -o - Output PDF file
  • --layers <layers> - Layers to include
  • --drawing-sheet <file> - Custom drawing sheet
  • --define-var <VAR=VALUE>, -D - Define variable
  • --mirror - Mirror output
  • --exclude-refdes - Exclude reference designators
  • --exclude-value - Exclude component values
  • --include-border-title - Include border and title block
  • --negative - Negative plot
  • --black-and-white - Force black and white
  • --theme <name> - Color theme to use
  • --drill-shape-opt <option> - Drill marks: 0 (none), 1 (small), 2 (actual)
Example:

SVG Export

Options: Similar to PDF export, plus:
  • --page-size <size> - Page size: A4, A3, A, B, C, D, E
  • --exclude-drawing-sheet - Exclude drawing sheet from output

DXF Export

Options:
  • --output <file>, -o - Output DXF file
  • --layers <layers> - Layers to export
  • --drawing-sheet <file> - Custom drawing sheet
  • --define-var <VAR=VALUE>, -D - Define variable
  • --output-units <units> - Output units: mm, in
  • --use-drill-file-origin - Use drill/place file origin

STEP/VRML 3D Export

Options:
  • --output <file>, -o - Output STEP file
  • --subst-models - Substitute 3D models with simplified shapes
  • --no-unspecified - Exclude components without 3D models
  • --no-dnp - Exclude DNP (Do Not Place) components
  • --board-only - Export board only (no components)
  • --include-tracks - Include tracks and vias
  • --include-zones - Include filled zones
  • --min-distance <dist> - Minimum distance for adjacent curves (default: 0.01mm)
  • --user-origin - Use user-defined origin
  • --origin <x,y,z> - Set custom origin coordinates
Example:

Position File Export

Options:
  • --output <file>, -o - Output position file
  • --side <side> - Side to export: front, back, both
  • --format <format> - Format: ascii, csv, gerber
  • --units <units> - Units: mm, in
  • --bottom-negate-x - Negate X coordinate for bottom side
  • --use-drill-file-origin - Use drill/place file origin
  • --smd-only - Include SMD components only
  • --exclude-dnp - Exclude DNP components

IPC-2581 Export

Options:
  • --output <file>, -o - Output IPC-2581 file
  • --units <units> - Units: mm, in
  • --compress - Compress output file

pcb drc

Run Design Rule Check.
Options:
  • --output <file>, -o - Output report file (JSON format)
  • --exit-code-violations - Return exit code 2 if violations found
  • --severity-all - Report all severities
  • --severity-error - Report errors only
  • --severity-warning - Report warnings and errors
Example:

pcb upgrade

Upgrade board file to current format.
Options:
  • --output <file>, -o - Output file (default: overwrites input)
  • --force - Force upgrade even if already current version

Schematic Commands

sch export

Export schematic to various formats.

PDF Export

Options:
  • --output <file>, -o - Output PDF file
  • --drawing-sheet <file> - Custom drawing sheet
  • --define-var <VAR=VALUE>, -D - Define variable
  • --black-and-white - Force black and white
  • --no-background-color - Remove background color
  • --exclude-drawing-sheet - Exclude drawing sheet
  • --theme <name> - Color theme

SVG Export

Options similar to PDF export.

Netlist Export

Options:
  • --output <file>, -o - Output netlist file
  • --format <format> - Format: kicad, orcadpcb2, cadstar, spice, spicemodel

BOM Export

Options:
  • --output <file>, -o - Output BOM file
  • --preset <name> - Use saved BOM preset
  • --format-preset <name> - Format preset (CSV, TSV, etc.)
  • --fields <fields> - Fields to include (comma-separated)
  • --labels <labels> - Field labels (comma-separated)
  • --group-by <fields> - Group by fields
  • --sort-field <field> - Sort by field
  • --sort-asc - Sort ascending
  • --filter <expr> - Filter expression
  • --exclude-dnp - Exclude DNP components
Example:

sch erc

Run Electrical Rule Check.
Options:
  • --output <file>, -o - Output report file (JSON format)
  • --exit-code-violations - Return exit code 2 if violations found
  • --severity-all - Report all severities
  • --severity-error - Report errors only
  • --severity-warning - Report warnings and errors

sch upgrade

Upgrade schematic file to current format.

Symbol Commands

sym export svg

Export symbol to SVG.
Options:
  • --output <dir>, -o - Output directory
  • --symbol <name> - Specific symbol to export (default: all)
  • --theme <name> - Color theme

sym upgrade

Upgrade symbol library to current format.

Footprint Commands

fp export svg

Export footprint to SVG.
Options:
  • --output <dir>, -o - Output directory
  • --footprint <name> - Specific footprint to export (default: all)
  • --theme <name> - Color theme
  • --layers <layers> - Layers to include

fp upgrade

Upgrade footprint library to current format.

Version Command

Displays KiCad version information including:
  • Version number
  • Build date
  • Commit hash
  • Libraries

Automation Examples

Complete PCB Manufacturing Package

CI/CD Integration

Exit Codes

  • 0 - Success
  • 1 - Error (invalid arguments, file not found, etc.)
  • 2 - Violations found (when using --exit-code-violations)

See Also