Introduction
This .brd file is the old board file of the PCB editor of
KiCad, the free electronics design suite. It is
line-based text that starts with PCBNEW-BOARD. KiCad 4.0 replaced it with
the S-expression .kicad_pcb file; KiCad 10.0 still
reads the old form. Other programs use .brd for unrelated formats.
There is no specification here to follow. This page describes what the legacy reader of KiCad 10.0 accepts, with details of what was written taken from the legacy writer kept in the source of KiCad 4.0.0.
Lines, values and units
- Each line starts with a keyword, followed by values separated by white space. The reader compares keywords without regard to case.
- Data is grouped in sections that open with a
$keyword, such as$MODULE, and close with a matching$End…line. - Inside most sections the reader passes over a line it does not know.
- A quoted string runs from the first
"on the line to the next unescaped one.\"stands for a quote and\\for a backslash; a backslash before any other character is kept. Text is read as UTF-8. - Lengths and coordinates are decimal numbers. The default unit is 0.1 mil (0.0001 inch, or 2.54 µm). A line
Units mmin$GENERALchanges the unit to millimetres. KiCad holds lengths in nanometres. - A length that is missing or is not a number stops the load with an error.
- Angles are in tenths of a degree.
- Counts, codes and layer numbers are decimal integers. Layer masks, attribute masks and time stamps are hexadecimal.
- Names of nets, texts and labels in the old notation mark an overbar with
~. KiCad converts it to~{…}: a second~, a space,}or)ends the bar, and~~is a plain tilde. A string that is only~, or that already holds~{, is left alone.
Header and versions
The first line is PCBNEW-BOARD Version N, which may go on with other
words, such as a date. Without a version number the reader assumes 1. It treats 7 as 2.
2 is the last version of this form, and KiCad rejects a higher one (a debug build of
KiCad skips that test).
One known difference between the versions is the encoding of pad names: version 1 holds them as single bytes, which the reader takes as Latin-1, and version 2 as UTF-8.
The writer in KiCad 4.0.0 puts the date after the version, then a blank line, a
comment line # Created by Pcbnew…, and writes encoding utf-8
inside $GENERAL.
PCBNEW-BOARD Version 2
$GENERAL
Units mm
LayerCount 2
BoardThickness 1.6
$EndGENERAL
$EQUIPOT
Na 0 ""
$EndEQUIPOT
$EQUIPOT
Na 1 "GND"
$EndEQUIPOT
$DRAWSEGMENT
Po 0 20 20 60 20 0.15
De 28 0 0 0 0
$EndDRAWSEGMENT
$TRACK
Po 0 25 30 45 30 0.25 -1
De 15 0 1 0 0
$EndTRACK
$EndBOARD
Sections
After the header the reader takes these sections. $EndBOARD ends the
board; a file that stops without it is an error. $GENERAL,
$SHEETDESCR and $SETUP come first, because later sections
depend on the unit and the layer count.
| Section | Ends with | Contents |
|---|---|---|
$GENERAL | $EndGENERAL | Units, layers and thickness |
$SHEETDESCR | $EndSHEETDESCR | Drawing sheet and title block |
$SETUP | $EndSETUP | Design settings |
$EQUIPOT | $EndEQUIPOT | One net |
$NCLASS | $EndNCLASS | One net class |
$MODULE name | $EndMODULE | One footprint |
$DRAWSEGMENT | $EndDRAWSEGMENT | One graphic shape |
$TEXTPCB | $EndTEXTPCB | One board text |
$COTATION | $endCOTATION | One dimension |
$PCB_TARGET or $MIREPCB | $EndPCB_TARGET or $EndMIREPCB | One alignment target |
$TRACK | $EndTRACK | All tracks and vias |
$ZONE | $EndZONE | Segments of old zone fills, discarded |
$CZONE_OUTLINE | $endCZONE_OUTLINE | One zone |
A missing end line is an error. The writer in 4.0.0 orders the file as: general,
sheet, setup, nets, net classes, footprints, board texts, shapes, targets and
dimensions, tracks, $ZONE, zones, $EndBOARD.
$GENERAL
| Line | Meaning |
|---|---|
Units mm | Lengths in the file are millimetres |
LayerCount n | Number of copper layers; 16 until set. It must come before EnabledLayers |
EnabledLayers mask | Hexadecimal layer mask of the enabled layers |
Ly mask | Older form: if there was no LayerCount, the number of bits set in the low 16 bits is the copper layer count |
BoardThickness t | Board thickness |
Nnets n or Nn n | Size of the table that maps net codes |
VisibleLayers mask | Mask of visible layers; ignored |
NoConn n | Ignored |
Di x1 y1 x2 y2 | Bounding box of the board; ignored |
Links, Ndraw, Ntrack, Nzone, Nmodule | Counts written by 4.0.0; KiCad 10.0 does not use them |
$SHEETDESCR
| Line | Meaning |
|---|---|
Sheet name width height [portrait] | Paper size by name; an unknown name is an error. Width and height are in mils and are used only for the size User |
Title "…", Date "…", Rev "…", Comp "…" | Title block: title, date, revision and company |
Comment1 "…" to Comment9 "…" | Comment lines; 4.0.0 writes the first four |
Layers
Layers are numbers from 0 to 28. Copper is numbered from the back to the front, the
opposite of .kicad_pcb.
| Number | Layer today |
|---|---|
| 0 | Back copper, B.Cu |
| 1 – 14 | Inner copper. With c copper layers, number n becomes inner layer c − 1 − n counted from the front |
| 15 | Front copper, F.Cu |
| 16, 17 | Adhesive, back and front |
| 18, 19 | Solder paste, back and front |
| 20, 21 | Silk screen, back and front |
| 22, 23 | Solder mask, back and front |
| 24 | Drawings, Dwgs.User |
| 25 | Comments, Cmts.User |
| 26, 27 | Eco1.User, Eco2.User |
| 28 | Board outline, Edge.Cuts |
- Other numbers outside the copper range are read as the comments layer, unless a section limits them first.
- A copper layer exists on a board if it is 15 or is less than the copper layer count.
- In a mask, bit n stands for layer n. If all of the low 16 bits are set, the mask means all copper layers.
$SETUP
All lines are settings; lengths use the file unit. When KiCad appends a board to another, it skips this section.
| Line | Meaning |
|---|---|
Layer[n] name [type] | Name (without spaces) and type of copper layer n. The type is signal, power, mixed, jumper, auxiliary, front or back; old files may leave it out |
TrackWidth w | Track width of the default net class |
TrackWidthList w | A further preset track width; repeated |
TrackClearence c | Clearance of the default net class (spelt so) |
TrackMinWidth w | Minimum track width |
ZoneClearence c | Zone clearance (spelt so) |
Zone_45_Only | Ignored |
DrawSegmWidth w | Default line width on copper |
EdgeSegmWidth w | Default line width of the board outline |
ViaSize d, ViaDrill d | Via diameter and drill of the default net class |
ViaMinSize d, ViaMinDrill d | Smallest via diameter and drill |
ViaSizeList d [drill] | A preset via size; repeated |
MicroViaSize d, MicroViaDrill d | Micro via diameter and drill of the default net class |
MicroViaMinSize d, MicroViaMinDrill d | Smallest micro via diameter and drill |
MicroViasAllowed n | Ignored |
TextPcbWidth w, TextPcbSize x y | Default thickness and size of text on copper |
EdgeModWidth w | Default footprint line width, silk screen and other layers |
TextModWidth w, TextModSize x y | Default footprint text thickness and size, silk screen and other layers |
PadSize x y, PadDrill d | Default pad size and drill |
Pad2MaskClearance c | Solder mask clearance around pads |
SolderMaskMinWidth w | Minimum width of solder mask |
Pad2PasteClearance c | Solder paste clearance |
Pad2PasteClearanceRatio r | Solder paste clearance as a plain ratio |
GridOrigin x y | Grid origin |
AuxiliaryAxisOrg x y | Auxiliary origin |
VisibleElements mask | Ignored |
PcbPlotParams (…) | Plot settings as one S-expression on the rest of the line |
Layers n | Written by 4.0.0; the count is taken from $GENERAL |
Plot settings
The S-expression after PcbPlotParams is read by the same parser as
pcbplotparams in a newer board, so its keywords are those listed under
plot settings of .kicad_pcb. Two points differ
from a current .kicad_pcb file:
- No format version is passed to the parser, so the hexadecimal bit sets of
layerselectionandplot_on_all_layers_selectionare taken in the layer numbering of early.kicad_pcbfiles (0 front copper, 31 back copper, 32 back adhesive and so on), not in the numbers used elsewhere in this file. - A
layerselectionthat is a plain number selects both silk screens and all copper.
The old item viasonmask sets via tenting for both sides of the board, and
the two readers of KiCad 10.0 disagree on its sense. The .kicad_pcb reader
takes yes (vias plotted on the mask layers) as untented. The legacy reader
passes the value on without inverting it, so there yes tents the vias and
no leaves them untented.
Nets and net classes
$EQUIPOT
Na 1 "GND"
St ~
$EndEQUIPOT
$NCLASS
Name "Power"
Desc "Supply nets"
Clearance 0.25
TrackWidth 0.5
ViaDia 0.8
ViaDrill 0.4
uViaDia 0.4
uViaDrill 0.2
AddNet "GND"
$EndNCLASS
Na code "name"gives a net its number and name; one$EQUIPOTmay hold only one. Net 0 is the unconnected net. The reader maps the numbers of the file to its own, and the rest of the file refers to the file’s numbers.Stis not read.- In
$NCLASS,NameandDescare the name and description,ClearanceandTrackWidththe rules,ViaDiaandViaDrillthe via, anduViaDiaanduViaDrillthe micro via. AddNet "name"puts a net in the class. It takes the class name as read so far, soNamehas to come earlier.- Two classes with the same name are an error.
Footprints
A footprint (called a module) opens with $MODULE name. KiCad takes the
name from the rest of that line and replaces characters that are not allowed in file
names.
$MODULE R_0805
Po 40 35 900 15 0 0 ~~
Li R_0805
Cd Resistor, 0805
Kw R
At SMD
T0 0 -1.6 1 1 900 0.15 N V 21 N "R1"
T1 0 1.6 1 1 900 0.15 N I 21 N "10k"
DS -0.4 -0.9 0.4 -0.9 0.15 21
$PAD
Sh "1" R 1 1.3 0 0 900
Dr 0 0 0
At SMD N 00888000
Ne 1 "GND"
Po -0.95 0
$EndPAD
$EndMODULE R_0805
| Line | Meaning |
|---|---|
Po x y angle layer edittime id [status] | Position, rotation, side (layer 0 or 15), time of last edit in hexadecimal, identifier, and two characters of status: F first for locked, P second for placed, ~ for neither. Old files may have no status |
Sc id | Identifier, a hexadecimal time stamp in old files |
Li name | Library name; not read, as the $MODULE line has it |
Cd text | Description, the rest of the line |
Kw text | Keywords, the rest of the line |
At … | Attributes. A line with SMD marks a surface mount part. Otherwise one with VIRTUAL leaves the part out of position files and the bill of materials; any other At line gives a through-hole part left out of position files |
AR path | Path of the schematic symbol |
Op a b … | Placement costs in hexadecimal, read by 4.0.0: the low four bits of a for turning by 90°, the next four a second cost, and the low four bits of b for turning by 180°. KiCad 10.0 ignores the line |
.SolderMask v, .SolderPaste v | Local solder mask and paste clearance |
.SolderPasteRatio r | Local paste ratio, limited to the range −0.5 to 0 |
.LocalClearance v | Local clearance |
.ZoneConnection n | How zones join the pads: −1 inherited, 0 none, 1 thermal relief, 2 solid, 3 thermal relief for through-hole pads only |
.ThermalWidth v, .ThermalGap v | Written by 4.0.0; KiCad 10.0 reads and ignores them on a footprint |
T… | Text |
DS, DC, DA, DP | Graphics |
$PAD … $EndPAD | Pad |
$SHAPE3D … $EndSHAPE3D | 3D model |
4.0.0 writes the . lines only when the value differs from the default,
and At only for a footprint that does.
The same blocks make up the
legacy footprint library
(.mod).
Footprint text
Tn x y height width angle thickness M|N V|I layer I|N "text" [L|C|R T|C|B]
- n is 0 for the reference, 1 for the value and another number for free text.
- The position is relative to the footprint. The angle in the file already includes the footprint’s rotation.
- The size is given height first. A thickness below 1 internal unit is read as 0.
Mis mirrored andNnot;Vis visible andIhidden; the field after the layer isIfor italic.- The last two letters are horizontal and vertical justification; the default is centred.
- Without a layer the text is on 21. A number below 0 is read as 0, the back copper, and one above 28 as 28. A written 0 becomes 20, and 1 to 15 become 21.
- A hidden free text is kept by KiCad 10.0 as a hidden user field of the footprint.
- Old files may have no space before the opening quote.
%Vand%Rin the text stand for the value and the reference.
Footprint graphics
| Line | Shape |
|---|---|
DS x1 y1 x2 y2 width layer | Segment |
DC cx cy px py width layer | Circle: centre and a point on it |
DA cx cy sx sy angle width layer | Arc: centre, start point and swept angle |
DP x1 y1 x2 y2 count width layer | Polygon, followed by count lines Dl x y |
Coordinates are relative to the footprint and turn with it. A layer outside 0 to 28 is
read as 21. Only lines that start with DS, DC,
DA or DP are graphics; other lines starting with
D are passed over. A missing Dl line is an error.
Pads
| Line | Meaning |
|---|---|
Sh "name" shape sx sy dx dy angle | Pad name, shape C circle, R rectangle, O oval or T trapezium (anything else is an error), size, trapezium deltas and rotation |
Dr d offx offy [O dx dy] | Drill diameter and offset of the pad shape from the hole; O with two sizes makes an oblong hole |
At type N mask | Type SMD, CONN (edge connector), HOLE (hole without plating) or STD (plated through hole, as is any other word); the second word is skipped; then the hexadecimal layer mask |
Ne code "name" | Net of the pad; the code decides |
Po x y | Position relative to the footprint |
Le v | Length from pad to die |
.SolderMask v, .SolderPaste v, .LocalClearance v | Local clearances |
.SolderPasteRatio r | Local paste ratio |
.ZoneConnection n | Zone connection, numbered as for footprints |
.ThermalWidth v, .ThermalGap v | Width of the thermal relief spokes and the gap |
The block closes with $EndPAD. KiCad 10.0 drops a pad whose width or
height is zero, with a message.
3D models
In $SHAPE3D, Na "file" names a model file,
Sc x y z is its scale, Of x y z its offset and
Ro x y z its rotation. KiCad copies these numbers as they are, without
applying the file’s length unit. An invalid number is an error.
Shapes, texts and targets
$DRAWSEGMENT
Po shape x1 y1 x2 y2 width: shape 0 segment, 1 rectangle, 2 arc, 3 circle, 4 polygon, 5 Bézier curve. For an arc the first point is the centre and the second the start; for a circle they are the centre and a point on it. A negative width is read as 0.De layer type angle id status [c1x c1y c2x c2y]: the layer is limited to 16 to 28; type is ignored; angle is the sweep of an arc; status is hexadecimal and ignored by 10.0; the last four numbers are the control points of a curve.
$TEXTPCB
Te "line"is the first line of the text and eachnl "line"adds one.Po x y sx sy thickness anglegives position, character size, stroke thickness and rotation.De layer n id style [h v]: n is 0 for mirrored and 1 for not; style isItalicorNormal; h and v are justification letters.- The layer is limited to 0 to 28, and a copper layer that the board does not have becomes the front copper.
$PCB_TARGET
Po shape layer x y size width id: shape 0 is a plus sign and another
number a cross; the layer is limited to 16 to 28.
Dimensions
| Line | Meaning |
|---|---|
Ge shape layer id | Shape number, layer and identifier |
Va value | Measured value; not used |
Te "text" | The text shown, taken as an override without a unit suffix |
Po x y sx sy thickness angle flag | Position, size, thickness and rotation of the text; flag 0 means mirrored |
Sb n x1 y1 x2 y2 width | The crossbar and the line width |
Sd n x1 y1 x2 y2 | First extension line; its first point is where the measurement starts |
Sg n x1 y1 x2 y2 | Second extension line; its first point is where the measurement ends |
S1 to S4 | The four arrow strokes, written in the same form as Sb: S1 and S2 start at the second point of the crossbar, S3 and S4 at the first. Ignored by 10.0 |
Tracks and vias
$TRACK holds two lines for each item, until a line that starts with
$.
Po viatype x1 y1 x2 y2 width [drill]: via type 1 micro, 2 blind or buried, 3 through (other numbers are read as through). A missing or negative drill means the default. A via has equal start and end points.De layer type net id status: type 1 is a via and anything else a track; net is the net code. In the status, hexadecimal, 4.0.0 defines 40000 as locked and 80000 as placed by the autorouter; KiCad 10.0 discards it.- A through via joins front and back copper. For other vias the layer value packs two copper numbers, one in each of its low two groups of four bits; if either layer does not exist on the board, the via is dropped.
- A track on a copper layer that the board does not have is dropped.
$ZONE uses the same pair of lines for the segments that filled zones in
old boards. KiCad 10.0 reads and discards them.
Zones
| Line | Meaning |
|---|---|
ZInfo id net "name" | Identifier, net code and net name; the code decides. An over-long name is an error |
ZLayer n | Layer |
ZAux corners N|E|F | Number of corners and hatching of the outline: none, edge or full. A missing or other letter is an error |
ZPriority n | Priority |
ZClearance c I|T|H|X | Clearance, and pad connection: solid, thermal relief, thermal relief for through-hole pads only, or none. Another letter is an error |
ZMinThickness w | Minimum width of the filled copper |
ZOptions mode segments S|F gap width | Fill mode, segments used to draw a circle, a flag that is S when the zone is filled, thermal gap and spoke width. A mode other than 0 is the old fill with segments; KiCad warns and uses polygons |
ZKeepout tracks Y|N vias Y|N copperpour Y|N | Makes the zone a keep-out area; N means not allowed. Pads and footprints stay allowed |
ZSmoothing type radius | Corner smoothing: 0 none, 1 chamfer, 2 fillet, with its size. Another type is an error |
ZCorner x y end | One corner of the outline. A non-zero end closes the contour; the next corner starts a hole |
$POLYSCORNERS … $endPOLYSCORNERS | The filled polygons, one x y end flag line per corner |
$FILLSEGMENTS … $endFILLSEGMENTS | Lines of four numbers, the ends of fill segments; ignored |
- A keep-out area gets no net, and neither does a zone off copper.
- If the minimum width is above zero, KiCad widens the stored filled polygons by half of it, with rounded corners.
- A zone with fewer than three corners is dropped.
Oddities of the KiCad 10.0 reader
- The code that sorts the preset track widths and via sizes and removes duplicates stands after the loop over
$SETUP, so a section that ends normally with$EndSETUPdoes not reach it. - The legacy plugin describes its board files as “Eagle ver. 6.x XML PCB files”.
- The error for an unclosed target names
$EndDIMENSION. - In KiCad 4.0.0 the code that saved this form is switched off in the source: KiCad no longer writes it.
Recognising and reading a file
Look for PCBNEW-BOARD at the start of the first line; that tells the file
apart from other formats with the extension .brd. Read the version, then
take sections until $EndBOARD, setting the unit and copper layer count
from $GENERAL before any length or layer is converted.
In the explorer
A dropped legacy board shows its sections and items as a byte tree and a drawing of the board: footprints with their pads, graphics and texts, tracks, vias, zone outlines and filled areas, board shapes, texts, targets and dimensions. Options choose the layers and the size of the picture. A click in the picture selects the bytes of the item. Tables list every footprint, pad, track, via, zone, drawing item, footprint text and graphic, net, net class, 3D model location and header line, and the lines of the general, sheet, setup and plot settings.
Files up to 400 MB are read.
Not described
Known, not yet covered
- Viewer, text: text is drawn in the site’s own stick font, not KiCad’s, with ASCII, accented Latin letters and some common signs; other characters are not drawn as themselves.
- Viewer, zone outlines: the hatching along the edge of a zone outline is not drawn, and the full hatching and the hatching of keep-out areas use the explorer’s own spacing.
- Viewer, local settings: solder mask and paste clearances are listed but not applied to the drawing.
Also used for
- EAGLE XML design file – XML circuit boards, schematics and libraries of EAGLE 6.0 and later.
- EAGLE binary board – Binary circuit board files of EAGLE versions 3, 4 and 5.
- EAGLE design file – EAGLE circuit boards, schematics and libraries, XML and older binary.
Links
Software
- KiCad – free electronics design suite; its PCB editor imports the format (Windows, macOS, Linux)
Developers
- KiCad source – the reference reader, GPL (C++)
Reference
- KiCad 10.0 legacy reader – what KiCad accepts today (C++)
- KiCad 4.0.0 legacy plugin – the older reader and the switched-off writer (C++)
- string_utils.cpp – quoted strings and the overbar conversion (C++)