Introduction
Drawing items have the same syntax in footprint files and board files. Most have two names: fp_… inside a footprint and gr_… on the board itself. This page covers what the KiCad 10.0 and 9.0 programs write and the older forms the 10.0 reader accepts. Square brackets mark optional parts, lengths are in millimetres and angles in degrees. The text syntax (quoting, booleans, uuid, stroke) is set out under symbol library syntax.
- In a footprint, the coordinates of lines, shapes, text and text boxes are relative to the footprint's position and turned with it. Zones, dimensions, images, barcodes and points are stored in board coordinates (the same thing in a library footprint, which sits at the origin).
tstampis the older name ofuuid.- On lines, shapes, text, text boxes, table cells and dimensions a bare
lockedword right after the item name is an older form of(locked yes). On these, except text, and on barcodes the list(locked)without a value also counts as yes.
Lines and shapes
(fp_line (start X Y) (end X Y) …)
(fp_rect (start X Y) (end X Y) [(radius R)] …)
(fp_circle (center X Y) (end X Y) …)
(fp_arc (start X Y) (mid X Y) (end X Y) …)
(fp_poly (pts (xy X Y) … ) …)
(fp_curve (pts (xy X Y) (xy X Y) (xy X Y) (xy X Y)) …)
then: (stroke (width W) (type …))
[(fill yes|no|hatch|reverse_hatch|cross_hatch)]
[(locked yes)]
(layer "NAME") | (layers "NAME" …)
[(solder_mask_margin M)] [(net "NAME")]
(uuid "…")- The end point of a circle is any point on it. The four points of a curve are start, first control point, second control point and end.
radiusrounds the corners of a rectangle (version 20250829, new in KiCad 10.0). - A polygon outline may mix
(xy X Y)points with(arc (start X Y) (mid X Y) (end X Y))segments (version 20210623). fillis written for rectangles, circles and polygons. The reader also acceptssolidfor yes andnonefor no. The hatched fills date from version 20250222 and are new in KiCad 10.0.layersis used when the shape is on more than one layer, which allows a copper shape with a matching solder mask opening (version 20241010).solder_mask_marginis written for a shape with mask on an outer copper layer.netapplies to copper shapes on a board. Before version 20251028 it was written as a code number.
Older forms
(width W)in place ofstroke, used before version 20211229.- Without any
fillitem, a rectangle or circle with zero line width is filled, and so is a polygon that is not onEdge.Cuts. An unfilled shape with no width gets the default width. - Arcs in files of version 20210925 or earlier are
(start CENTRE) (end ARC_START) (angle A). angleon other shapes and(status HEX)are read and ignored.
Text
(fp_text user "TEXT" | gr_text "TEXT"
[(locked yes)]
(at X Y [ANGLE])
[(unlocked yes)]
(layer "NAME" [knockout])
(uuid "…")
(effects …)
[(render_cache …)])- The angle of footprint text is the total angle on the board, including the footprint's rotation. The position is relative.
- Footprint text is kept upright (readable from the bottom or right) unless
unlocked yesis given. Older files put a bareunlockedinsideat. knockoutdraws the text as a hole in a filled box.- Besides
user, the reader acceptsreferenceandvalueafterfp_text, the form used before fields became properties (version 20230620); they set those two fields. In old text,%Vand%Rare read as${VALUE}and${REFERENCE}. (hide yes)or a barehideis accepted in footprints; hidden user text becomes a hidden user field. Text on the board is always made visible.
Effects
(effects
(font [(face "NAME")] (size HEIGHT WIDTH) [(line_spacing R)]
[(thickness T)] [(bold yes)] [(italic yes)])
[(justify [left|right] [top|bottom] [mirror])])- Without
justifythe text is centred both ways and not mirrored. A font with nosizegets 1.524 mm. boldanditalicalso occur as bare words in older files.- The reader also accepts
(hide yes)or a barehideinsideeffects, an older place for it that KiCad 9.0 and 10.0 do not write. - In files older than version 20210606 an overbar is written
~…~; the reader converts it to~{…}.
Render cache
Text in an outline font also stores its drawn shape: (render_cache "TEXT" ANGLE (polygon (pts …) [(pts …) …]) …). Each polygon is a glyph part; the first pts list is its outline and any further lists are holes.
Text boxes
(fp_text_box "TEXT" | gr_text_box "TEXT"
[(locked yes)]
(start X Y) (end X Y) | (pts (xy X Y) …)
(margins LEFT TOP RIGHT BOTTOM)
[(angle A)]
(layer "NAME")
(uuid "…")
(effects …)
(border yes|no)
(stroke …)
(knockout yes|no)
[(render_cache …)])- An upright box is given by
startandend; a rotated one by the corner points inpts, withanglesetting only the direction of the text. In a footprint the angle is relative to the footprint. - The
knockoutitem is new in KiCad 10.0; 9.0 neither writes nor reads it on a text box. - Text boxes date from version 20220131. Files older than 20230825 have no
borderitem; there a stroke width of zero or more means a border is drawn. Withoutmarginsthe reader works out the margin the old way.
Tables
(table
(column_count N)
(uuid "…")
[(locked yes)]
(layer "NAME")
(border (external yes|no) (header yes|no) [(stroke …)])
(separators (rows yes|no) (cols yes|no) [(stroke …)])
(column_widths W …)
(row_heights H …)
(cells
(table_cell "TEXT"
[(locked yes)]
(start X Y) (end X Y) | (pts …)
(margins L T R B)
(span COLUMNS ROWS)
[(angle A)]
(layer "NAME")
(uuid "…")
(effects …)
[(render_cache …)]) …))- Cells are listed row by row. A
strokeis written for the border or the separators only when one of their two lines is switched on. - Tables date from version 20240202 and table identifiers from 20250907. The reader skips an empty
(angle)item on the table itself; one with a value is an error.
Images
(image (at X Y) (layer "NAME") [(scale S)] [(locked yes)]
(data "BASE64" …)
(uuid "…"))The picture file is stored as Base64 text split over several strings. scale is written when it is not 1; the reader replaces an abnormal value with 1.
Barcodes
(barcode [(locked yes)]
(at X Y ANGLE)
(layer "NAME")
(size W H)
(text "…")
(text_height H)
(type code39|code128|datamatrix|qr|microqr)
[(ecc_level L|M|Q|H)]
(hide yes|no)
(knockout yes|no)
[(margins X Y)]
(uuid "…"))- Barcodes date from KiCad 10.0 (version 20250914). Besides the type names above, the reader also accepts
data_matrix,qrcodeandmicro_qr, and lower-case error correction letters. ecc_levelis written for the two QR types.hidehides the readable text under the code.- The encoded
textmust be a quoted string. - The file holds the text, not the modules of the symbol: a reader encodes it. KiCad stretches the symbol to
sizeaboutat, puts the readable text 1 mm below it, and forknockoutfills a box around both, wider than them bymarginsand at least by a tenth of the shorter side (rounded up to 0.1 mm), and cuts both out of it. On a back layer the result is mirrored, then it is turned by the angle.
The symbologies
- Code 39 (ISO/IEC 16388) and Code 128 (ISO/IEC 15417), the linear types.
- Data Matrix (ISO/IEC 16022) and QR Code with Micro QR (ISO/IEC 18004), the matrix types. KiCad draws all five with the zint library; the zxing-cpp decoder shows the same symbol tables from the reading side.
Dimensions
(dimension (type aligned|orthogonal|leader|center|radial)
[(locked yes)]
(layer "NAME")
(uuid "…")
(pts (xy X Y) (xy X Y))
[(height H)] aligned and orthogonal
[(leader_length L)] radial
[(orientation 0|1)] orthogonal
[(format (prefix "…") (suffix "…") (units N) (units_format N)
(precision N) [(override_value "…")] [(suppress_zeroes yes)])]
(style (thickness T) (arrow_length L) (text_position_mode N)
[(arrow_direction inward|outward)] aligned and orthogonal
[(extension_height H)] aligned and orthogonal
[(text_frame N)] leader
(extension_offset O)
[(keep_text_aligned yes)])
[(gr_text …)])| Item | Values |
|---|---|
orientation | 0 horizontal, 1 vertical |
units | 0 inches, 1 mils, 2 millimetres, 3 automatic |
units_format | 0 no unit suffix, 1 plain suffix, 2 suffix in brackets |
precision | 0 to 5 decimal places; 6 to 9 are variable settings whose decimals depend on the unit (from 0.00 / 0 / 0.0 up to 0.00000 / 0.00 / 0.0000) |
text_position_mode | 0 outside the line, 1 in line, 2 placed by hand |
text_frame | 0 none, 1 rectangle, 2 circle, 3 rounded rectangle |
- The points are the two features measured.
formatand the text are not written for acentermark. arrow_directiondefaults tooutward. Astylelist withoutkeep_text_alignedturns that setting off.
Older forms
(dimension VALUE (width W) …)without atypeis an aligned dimension. Its units are guessed from the text, or left automatic.- Its geometry is in
feature1,feature2andcrossbar, each holding(pts (xy …) (xy …)): the first point of each feature line is the measured start or end, and the crossbar gives the height.arrow1a,arrow1b,arrow2aandarrow2bare ignored.
Points and targets
(point (at X Y) (size S) (layer "NAME") (uuid "…"))A point marks a position for snapping and was added in version 20250901. The board-only target mark is (target plus|x (at X Y) (size S) [(width W)] (layer "NAME") (uuid "…")).
Divergence from spec
The KiCad developer documentation covers the drawing items of KiCad 6.0 to 8.0. It does not describe barcodes, points, hatched shape fills, rounded rectangles or shapes on more than one layer.
Links
Developers
- KiCad source code – reader and writer in
pcbnew/pcb_io/kicad_sexpr(C++, GPL)
Reference
- S-expression format introduction – KiCad developer documentation, graphic items