What Is the Gerber Format?
Gerber is the de facto standard file format for describing printed circuit board (PCB) artwork — the copper traces, solder mask openings, silkscreen legends, and board outlines that PCB manufacturers use to fabricate circuit boards. Originally developed by Gerber Scientific Instruments in the 1960s for vector photoplotter machines, Gerber has evolved through several versions into the modern RS-274X (Extended Gerber) standard, now maintained and freely published by Ucamco (who acquired the Gerber technology in 2012).
When you order a PCB from any fabricator — JLCPCB, PCBWay, OSH Park, Advanced Circuits, or any professional fab — you submit a set of Gerber files. Every PCB CAD tool can export Gerber; every fabrication house accepts it. It is the PostScript of the electronics manufacturing world.
The Gerber File Set
A complete PCB is described by a set of Gerber files, each representing one layer:
| Layer | Typical Extension | Description |
|---|---|---|
| Front copper | .GTL (Top Layer) |
Top-side copper traces and pads |
| Back copper | .GBL (Bottom Layer) |
Bottom-side copper |
| Inner layers | .G1, .G2, … |
Internal copper layers for multilayer boards |
| Front solder mask | .GTS (Top Solder) |
Openings in the green lacquer — exposes pads |
| Back solder mask | .GBS (Bottom Solder) |
Bottom-side mask openings |
| Front silkscreen | .GTO (Top Overlay) |
Component labels and reference designators |
| Back silkscreen | .GBO (Bottom Overlay) |
Bottom-side text |
| Board outline | .GKO or .GM1 |
Edge cuts — defines the PCB shape |
| Drill file | .DRL or .XLN |
Excellon-format drill coordinates and sizes |
| Paste mask | .GTP, .GBP |
Stencil openings for solder paste application |
KiCad (the dominant open-source PCB EDA tool) exports this exact structure by default. Altium Designer uses a similar naming convention with .GTL, .GBL, .GTS, etc.
RS-274X Format Structure
A Gerber file is a plain ASCII text file. The format is command-based:
%FSLAX46Y46*% ; Format Specification: 4 integer, 6 decimal digits, absolute coords
%MOMM*% ; Units: Millimeters
%LPD*% ; Layer Polarity: Dark (default)
; Aperture definitions
%ADD10C,0.200000*% ; Aperture #10: Circle, diameter 0.200000 mm
%ADD11R,1.600000X0.800000*% ; Aperture #11: Rectangle, 1.6mm × 0.8mm
%ADD12O,1.000000X0.600000*% ; Aperture #12: Oblong (rounded rect), 1.0mm × 0.6mm
%ADD13P,0.500000X6*% ; Aperture #13: Regular polygon, 0.5mm diameter, 6 sides
; Commands
D10* ; Select aperture #10 (0.2mm circle)
X150000Y200000D02* ; Move to (1.500000, 2.000000) mm — no draw
X300000Y200000D01* ; Linear draw to (3.000000, 2.000000) mm
X450000Y200000D03* ; Flash aperture at (4.500000, 2.000000) — creates a pad
D11* ; Switch to rectangle aperture
X250000Y150000D03* ; Flash SMD pad
G01* ; Linear interpolation mode (default)
G02* ; Clockwise arc interpolation
G03* ; Counter-clockwise arc interpolation
M02* ; End of file
Coordinates are encoded as integers with implicit decimal points — X150000 with format X46 means 1.500000 mm (4 integer digits + 6 decimal digits).
Apertures in Detail
Apertures define the shapes used to draw traces and flash pads:
| Aperture Type | Code | Description | Use |
|---|---|---|---|
| Circle | C |
Diameter parameter | Round traces, round pads |
| Rectangle | R |
Width × Height | SMD component pads |
| Oblong | O |
Width × Height | Elongated pads |
| Polygon | P |
Diameter, vertices, rotation | Hex/octagon pads |
| Macro | %AMNAME*...% |
Arbitrary complex shape | Custom pad shapes |
Macros can define complex shapes using primitives like circles, lines, and rectangles combined with arithmetic expressions:
%AMTHERMAL*
1,1,0.6,0,0,0* ; solid circle, diameter 0.6mm
1,0,0.4,0,0,0* ; clear circle, diameter 0.4mm
20,1,0.15,-0.3,0,0.3,0,0* ; line across horizontal
20,1,0.15,0,-0.3,0,0.3,0* ; line across vertical
%
This macro defines a thermal relief aperture — a pad with spokes connecting it to a copper pour, reducing heat sinking during soldering.
The Excellon Drill File
The drill file is a companion to the Gerber set, typically in Excellon format (not technically Gerber, but always distributed alongside):
%
FMAT,2
METRIC,TZ
T1C0.300 ; Tool #1: 0.3mm diameter
T2C0.600 ; Tool #2: 0.6mm diameter
T3C1.016 ; Tool #3: 1.016mm diameter (standard through-hole pin)
%
G90 ; Absolute coordinates
G05 ; Drill mode
T1 ; Select 0.3mm drill
X0.45Y0.35 ; Drill at (0.45, 0.35) mm
X1.25Y0.35 ; Drill at (1.25, 0.35) mm
T2 ; Select 0.6mm drill
X2.50Y1.10 ; Drill at (2.50, 1.10) mm
T3 ; Select 1.016mm through-hole drill
X0.85Y2.10
M30 ; End of file
Modern fabricators accept drill files in Excellon 2 format, which adds units headers and tolerances. KiCad generates .drl files automatically alongside the Gerber export.
Gerber X2: Structured Metadata
Gerber X2 (released 2014, standardized as IPC-2581 alternative) adds structured metadata attributes embedded as comment lines:
%TF.FileFunction,Copper,L1,Top*% ; This file = copper, Layer 1, Top
%TF.FilePolarity,Positive*% ; Dark apertures = copper
%TF.SameCoordinates,Original*% ; All files share same coordinate origin
%TF.CreationDate,2024-03-15T14:30:00*%
%TF.GenerationSoftware,Kicad,Pcbnew,8.0.1*%
%TF.ProjectId,MyProject,{uuid},1.0*%
%TA.AperFunction,SMDPad,CopperDef*% ; Next aperture defines an SMD pad
%ADD10C,0.2*%
Gerber X2 attributes allow automated CAM software to understand which layer is which without relying on file naming conventions — critical when file names get scrambled by email clients or zip utilities.
Exporting Gerbers from KiCad
KiCad's Gerber export workflow:
- Open PCB editor → File → Fabrication Outputs → Gerbers
- Select output folder and layers to export
- Enable Use Protel filename extensions (GTL, GBL, etc.) for maximum fab compatibility
- Enable Generate drill files → select Excellon format
- Click Plot and Generate Drill Files
- Zip the folder and upload to your PCB fab
# Automated KiCad Gerber export via scripting (KiCad 7+)
import pcbnew
board = pcbnew.LoadBoard("myboard.kicad_pcb")
pctl = pcbnew.PLOT_CONTROLLER(board)
popt = pctl.GetPlotOptions()
popt.SetOutputDirectory("./gerbers/")
popt.SetPlotFrameRef(False)
popt.SetUseGerberX2format(True)
popt.SetIncludeGerberNetlistInfo(True)
# Plot each layer
for layer_id, suffix in [(pcbnew.F_Cu, "GTL"), (pcbnew.B_Cu, "GBL"),
(pcbnew.F_Mask, "GTS"), (pcbnew.B_Mask, "GBS"),
(pcbnew.F_SilkS, "GTO"), (pcbnew.Edge_Cuts, "GKO")]:
pctl.SetLayer(layer_id)
pctl.OpenPlotfile(suffix, pcbnew.PLOT_FORMAT_GERBER, suffix)
pctl.PlotLayer()
pctl.ClosePlot()
Viewing and Validating Gerber Files
Before submitting to a fab, always inspect your Gerbers with a viewer:
- KiCad GerbView (free, included with KiCad) — open multiple layers, check alignment
- Gerbv (free, open-source, Linux/Windows/macOS)
- ViewMate (Pentalogix, free tier) — industry standard on Windows
- GerberHub.io — web-based, drag-and-drop, instant preview
- EasyEDA Gerber Viewer — web-based
Check for: missing layers, misaligned drill holes on pads, unintentional copper shorts, silkscreen overlapping solder mask openings.
Reading Gerber Files with Python
pygerber provides full RS-274X parsing:
from pygerber.gerberx3.api.v2 import GerberFile
# Parse and render a Gerber file to PNG
file = GerberFile.from_file("board_top_copper.gtl")
image = file.parse().render_with_pillow()
image.save_as("top_copper_preview.png")
Related conversions
Frequent conversions across the catalogue: