Layout Knowledge Base

Files · Boards

What is a Gerber file? The plot format for PCB layers

A Gerber file is a text file that describes one layer of a printed circuit board as a 2D vector image built from apertures, flashes, draws, and regions.

Last edited: October 19, 2026

Six Gerber files of one 40 × 25 mm board read into LayoutEditor: copper tracks, pads and ground pour, solder-mask openings, component outlines, drill hits, and the board profile.

A Gerber file is a text file that describes one layer of a printed circuit board (PCB) as a two-dimensional binary image: every point of the board is either dark, which means material such as copper is present, or clear. Gerber is the format PCB fabricators expect for copper, solder mask, legend (silkscreen), paste, drill, and board-outline data. Ucamco publishes the format as The Gerber Layer Format Specification; the current revision is 2026.05, released in May 2026. The current format is also called RS-274X or Extended Gerber. A file without attributes is Gerber X1, a file with attributes is Gerber X2 (introduced in 2014), and Gerber X3 (2020) adds component layers for assembly. The specification asks for the file extension .gbr.

The image at the top of this page is six Gerber files of one 40 × 25 mm board, each read by LayoutEditor onto its own layer. Copper is orange: tracks, pads, and a ground pour that contains two mounting pads inside a cleared ring and two vias tied in by four spokes each. The green hatch marks the solder-mask openings over the pads. Black lines are the legend with the component outlines and the board profile. The dark disks are the plated and non-plated drill hits.

Where the name and the plot model come from

The format is named after Joseph Gerber, whose company supplied vector photoplotters from the 1960s on. A vector photoplotter exposes photographic film with a light beam. A wheel of apertures, openings of fixed shape and size, sits in the light path. The plotter flashes an aperture at a position to expose a pad, and it moves the head with the light on to draw a track. The plotter input was a subset of the EIA RS-274-D numerical-control (NC) format. Gerber published it in 1980, and it became known as Standard Gerber. A Standard Gerber job needed two files: the coordinates and a separate list of the apertures mounted on the wheel. A pad shape that was not on the wheel had to be painted with many small draws.

Raster laser photoplotters replaced vector plotters from the 1980s on. They expose any shape pixel by pixel, and fabricators started to ask for data instead of film. RS-274X, published by Barco (now Ucamco) on September 21, 1998, moved the aperture definitions and the coordinate format into the file, so that each file is a complete image description. In September 2014 Ucamco declared Standard Gerber obsolete and revoked it. The command names still describe plotter actions: a pad is a flash, a track is a draw, and the shape that is flashed or drawn is the current aperture.

A photoplotter head above a sheet of film on the machine table

The photograph shows a laser photoplotter head above a film on the machine table. Many fabricators now skip the film and expose the photoresist on the panel directly from the data; the input is still the Gerber image.

What a Gerber file contains

A Gerber file is a stream of commands that a reader processes once, from start to end. Apertures, macros, and parameters must be defined before they are used. Commands and names use printable 7-bit ASCII; attribute values may use UTF-8. Every command ends with *, and extended commands are enclosed in %. The specification states that "Gerber is not a programming language": a file has no loops, conditions, or procedure calls.

Command Function Example
MO unit, millimeter (MM) or inch (IN); once, in the header %MOMM*%
FS coordinate format: integer and decimal digits %FSLAX26Y26*%
AD defines an aperture and gives it a D code of 10 or higher %ADD10C,1.600000*%
AM defines an aperture macro, a parametric shape of any form %AM…*%
Dnn (nn ≥ 10) selects the current aperture D10*
D01 plot: draw a segment from the current point to the coordinate X4750000Y5400000D01*
D02 move the current point without creating an image X2000000Y2000000D02*
D03 flash the current aperture at the coordinate X8000000Y2000000D03*
G01, G02, G03 plot state: linear, clockwise arc, counterclockwise arc G01*
G36, G37 start and end a region, a filled closed contour G36*
LPD, LPC polarity of the following objects: dark or clear %LPC*%
TF, TA, TO, TD attributes of the file, of apertures, of objects; delete an attribute %TF.FileFunction,Copper,L1,Top*%
M02 end of file M02*

The standard apertures are the circle C, the rectangle R, the obround O, and the regular polygon P; sizes are given in the file unit. The commands create four kinds of graphical objects. A draw is a straight segment stroked with a circular aperture; its width equals the aperture diameter, and its ends are round. An arc is the same for a circular segment. A flash places one copy of the current aperture at a point. A region is the area inside a closed contour. On a copper layer, tracks are draws and arcs, pads are flashes, and copper pours are regions (specification, section 2.3).

A complete example file

The following file is the top copper of a board fragment of 16 × 7 mm. The third figure and the LayoutEditor test further down use exactly this file.

%TF.FileFunction,Copper,L1,Top*%
%MOMM*%
%FSLAX26Y26*%
%ADD10C,1.600000*%
%ADD11R,1.500000X0.800000*%
%ADD12C,0.250000*%
%ADD13C,2.400000*%
G01*
D12*
X2000000Y2000000D02*
X4750000Y5400000D01*
D10*
X2000000Y2000000D03*
X8000000Y2000000D03*
D11*
X4750000Y5400000D03*
G36*
X10000000Y0D02*
X16000000Y0D01*
X16000000Y7000000D01*
X10000000Y7000000D01*
X10000000Y0D01*
G37*
%LPC*%
D13*
X13000000Y4000000D03*
%LPD*%
D10*
X13000000Y4000000D03*
M02*

The TF line is an X2 file attribute: this file is copper layer L1, the top side. Production files usually also carry .FilePolarity and .GenerationSoftware; they are left out here to keep the listing short. %MOMM*% sets millimeters. %FSLAX26Y26*% allows two integer digits and six decimal digits, so X2000000 means 2.000000 mm. The four AD lines define a round pad D10 with a diameter of 1.6 mm, a rectangular pad D11 of 1.5 × 0.8 mm, a 0.25 mm circle D12 for tracks, and a 2.4 mm circle D13 for a clearance. G01* sets linear plotting. The specification requires a plot state before the first D01, because it is undefined at the start of a file.

With D12 selected, D02 moves to (2, 2) mm and D01 draws a track to the rectangular pad. The D03 lines flash two round pads and the rectangular pad. Between G36 and G37, a closed contour defines a 6 × 7 mm copper pour. %LPC*% switches to clear polarity, and the flash of D13 erases a disk from the pour. %LPD*% switches back to dark, and a round pad is flashed at the center of that disk. A gap of 0.4 mm now separates the pad from the pour. M02* ends the file.

The example file read twice by LayoutEditor: the final image above, the stored objects below

The upper half of the figure is the final image of the file: the clear disk is subtracted from the pour and leaves a ring of bare laminate around the inner pad. The lower half shows the same file as stored objects, read with the LayoutEditor option Inverse Shapes On Other Layer: three round pads, the rectangular pad, the track with round ends, and the pour on the copper layer, and the clear disk (blue hatch) on a separate layer above the pour. The scale bar is 2 mm.

The final image depends on the order of the objects. A dark object darkens the plane. A clear object erases every dark area beneath it, including objects from earlier in the file. A later dark object darkens the plane again. If the inner pad were flashed before %LPC*%, the clear disk would erase it as well. The specification recommends this sequence of dark and clear objects for holes in a pour. A contour with a cut-in is allowed under conditions, and cutting one pour into pieces around its clearances is listed as a bad practice. Merging, subtraction, and holes in layout data are covered in AND, OR, NOT, XOR and holes in polygons.

Coordinates, units, and resolution

Gerber coordinates are Cartesian and seen from the top of the board: X points to the right, Y points up. The origin can be anywhere, but the specification recommends the bottom-left corner of the board. All files of one board must use the same coordinate system, so that a drill hit, its pad, and its solder-mask opening have identical coordinates.

MO sets the unit once, before the first operation. The specification says: "Use metric. Imperial is historical and will be deprecated at a future date." FS sets the number of integer digits, 1 to 6, and of decimal digits. Revision 2026.05 requires six decimal digits; in millimeters this is a resolution of 10⁻⁶ mm, or 1 nm. Fewer decimals, called low resolution, have been deprecated since revision 2015.06. The specification names low resolution as the root cause of most problems with Gerber files: poor registration between layers, self-intersecting contours, invalid arcs, and missing clearances. Omitting trailing zeros has been deprecated since the same revision.

Coordinates are integers with an implied decimal point, so a reader must apply the MO and FS values that the writer used. Two misreads of the example file were measured with LayoutEditor:

Header line Pour read as Round pad read as Cause
%MOMM*% and %FSLAX26Y26*% (as written) 6.0 × 7.0 mm 1.60 mm —
%MOIN*% instead of %MOMM*% 152.4 × 177.8 mm 40.64 mm every coordinate and every aperture size is read in inches, a factor of 25.4
%FSLAX25Y25*% instead of %FSLAX26Y26*% 60.0 × 70.0 mm 1.60 mm coordinates are read with five decimals, a factor of 10; aperture sizes carry their own decimal point and stay unchanged

The second misread is harder to notice, because no single shape has an implausible size: pad diameters and track widths come from the apertures and stay correct, while positions, track lengths, and region corners are scaled.

The example file at its correct size and the same file read with a five-decimal format

The orange group at the bottom left is the example file as written. The blue drawing is the same file after its format line was changed to %FSLAX25Y25*%, read by LayoutEditor at the same scale: the pour has grown to 60 × 70 mm, while the pads, the track, and the white clearance ring keep their aperture sizes. The scale bar is 10 mm.

Excellon drill files have the same weakness. The header states inch or metric and which zeros are omitted, and the number format is often implied. The LayoutEditor manual documents its own Excellon output as inches with leading zeros kept and an implied 2.4 format, so X0125 stands for 01.2500 inch. A reader with a different zero mode or digit count places every hole elsewhere.

One file per layer: the fabrication data set

Each Gerber file holds one image, so a board is delivered as a set of files. In Gerber X2 the attribute .FileFunction states what a file is, for example Copper,L1,Top, Soldermask,Top, Legend,Top, Plated,1,2,PTH, or Profile,NP. Without attributes the fabricator assigns files by name and by the table of names on its website. The specification also asks for:

  • a profile layer with the board outline in every data set;
  • drill and rout data as Gerber files, with plated (PTH) and non-plated (NPTH) holes in separate files and each hole at its finished diameter; if an NC format is required, Ucamco's XNC format, although Excellon drill files remain widely exchanged;
  • a netlist, as an IPC-D-356A file or as Gerber net attributes, so that the fabricator can check the image against the intended connections;
  • a Gerber job file (.gbrjob, JSON) that lists the files and the layer structure.

Gerber does not store the layer stack, the materials, or the copper weight. Foil thickness is one of the facts the plot leaves out; copper as a PCB layer explains the 1 ounce foil of about 35 µm under the outlines the plot stores. Layer order and dielectric thickness are described in the PCB stackup, which travels in the job file or in the fabrication drawing. The full order, with plots, drill file, stackup, outline, and a note that states units, copper count, and surface finish, is covered in sending a board to a PCB fab.

Common errors in Gerber data

The following table combines the bad practices in section 7.2 of the specification with the deprecated elements in section 8.

Error Effect Remedy
a D code is used before its AD definition the file is invalid; readers differ in what they draw define all apertures in the header
the first D01 comes before G01 the plot state is undefined; the file is invalid write G01* before the first draw
a wrong MO or FS value in the file or in the reader the board is scaled by 25.4 or by a power of 10 metric units, six decimals, check the board size in a viewer
low resolution (fewer than six decimals) layers misregister, contours self-intersect, small clearances disappear six decimals
painted pads or pours (areas filled with many draws) large files; the fabricator cannot identify pads for electrical test flash pads, draw pours as regions
pads written as contours or zero-length draws pads cannot be identified flash pads with AD or AM apertures
a pour cut into pieces around its clearances pour and clearances must be reconstructed by hand one region plus clear objects
no profile layer, or the outline only inside a copper file the outline must be guessed a separate profile file
no netlist no independent check of the image IPC-D-356A or net attributes
deprecated commands such as IP, MI, SF, or OF readers interpret them differently or ignore them current commands only
non-standard extensions such as .top or .bot the file type must be guessed .gbr

Gerber in LayoutEditor

LayoutEditor reads and writes RS-274X. Because a Gerber file holds one layer, the manual describes three ways to read one: open creates a new cell and puts the data on the active layer, import adds the data to the current cell on the active layer, and update replaces everything on the active layer of the current cell. A Gerber file has no hierarchy, so saving writes a flat copy: every used layer goes to its own file named filename-layername.gbx, and LayoutEditor also writes a macro that loads all of these files again. In LayoutScript, saveLayer(fileName, layer) writes a single layer. The manual lists four Gerber options:

  • Inverse Shapes On Other Layer: objects with clear polarity are placed on the next layer up. With the option off, LayoutEditor combines dark and clear objects by boolean operations into the final image.
  • Save Arcs: paths are checked for arcs, and arcs are written with circular interpolation instead of straight segments.
  • Save Optimize: the output is ordered for minimal travel without exposure, for files that drive a plotter.
  • Save regular polygon as circle: LayoutEditor and GDSII store circles as regular polygons; with this option, a regular polygon with more than 8 points is written as a circle.

The LayoutScript program below reads the example file with the first option on, counts the objects per layer and type, and writes layer 1 back as a Gerber file:

from collections import Counter
from LayoutScript import project, setup

setup.gerberInverseShapesOnOtherLayer = True   # clear objects go one layer up
layout = project.newLayout()                    # database unit 1 nm
drawing = layout.drawing
drawing.activeLayer = 1                         # Gerber data lands on the active layer
drawing.importFile("fragment.gbr")

def kind(el):
    if el.isPath(): return "path"
    if el.isBox(): return "box"
    if el.isCircle(): return "circle"
    return "polygon"

found = Counter()
e = drawing.currentCell.firstElement
while e is not None:
    found[(e.thisElement.layerNum, kind(e.thisElement))] += 1
    e = e.nextElement
for (layer, k), n in sorted(found.items()):
    print(f"layer {layer}: {n} {k}")

drawing.saveLayer("fragment-layer1.gbr", 1)     # layer 1 back out as Gerber
layer 1: 1 box
layer 1: 3 circle
layer 1: 1 path
layer 1: 1 polygon
layer 2: 1 circle

The flashed round pads arrive as circles, the rectangular pad as a box, the track as a path with the aperture width of 0.25 mm, and the region as a polygon; the clear disk is a circle on layer 2. With the option off, the same file gives four shapes on layer 1: the inner pad, the pour with its hole, the single round pad, and the track merged with the two pads it connects.

Two results of a round trip were measured with this file. The file written from layer 1 after reading with the option on contains the pour as a region but no clearance, because the clear disk stays on layer 2; the inner pad is then connected to the pour. Writing the merged result instead gives the correct copper image, but only the two isolated round pads remain flashes; the pour and the connected pads and track are written as two regions with 157 contour vertices. For measuring copper, read with the option off; to inspect how a file was built, read with the option on. The design itself stays in a layout format, and Gerber is written from it for each release.

LayoutEditor also reads Excellon drill files, which hold only circles on a single layer, and ODB++ data sets: the ODB++ directory tree must be uncompressed, and the file to open is the matrix file in its matrix folder.

Gerber compared with ODB++, IPC-2581, GDSII, and OASIS

Format Owner or standard Structure Content
Gerber X2/X3 Ucamco, specification revision 2026.05 one ASCII file per layer image images plus attributes: file function, pad function, nets, components
ODB++ Siemens (originally Valor) a directory tree, usually compressed into one archive layers, components, nets, and stackup of one job
IPC-2581 (IPC-DPMX) IPC, revision C one XML file fabrication, assembly, stackup, netlist, and bill of materials
GDSII de facto standard for IC mask data one binary file of cells and cell references all layers by layer and datatype number, with hierarchy
OASIS SEMI P39 one binary file the content of GDSII in a more compact encoding

Gerber files with Excellon or Gerber drill files remain the most common input of PCB fabricators. IC mask data takes the other path: a GDSII or OASIS file keeps cells and references up to the mask shop, while a Gerber set is flat and holds one layer per file. Footprints, the board-level counterpart of cells, are covered in footprints are almost cells.

Before a Gerber set goes to a fabricator, open every file in a viewer that reads X2 attributes and check five points: the profile measures the expected board size in millimeters; the file function of each file matches its name; every drill hit lies on a pad in both outer copper files; each clearance in a pour appears as a gap in the final image and not only as a separate clear object; and a netlist file is part of the set.

Continue exploring