The Gerber file format: what is inside a .gbr file
What the Gerber file format is, how a Gerber file is written line by line, the difference between RS-274-D, RS-274X, Gerber X2 and X3, and what that means when you open one in an online Gerber viewer.
Last reviewed
The Gerber format is the open, plain-text vector format PCB tools use to describe each layer of a board: copper, solder mask, silkscreen, paste and the outline. One Gerber file holds one layer image. It is maintained by Ucamco, which publishes the specification as a free PDF on its Gerber format downloads page, and it is named after Joseph Gerber, whose company built the photoplotters the format was first written for.
This page is about the format itself: what the commands in a file mean and which version you are looking at. For the set of files a manufacturer needs (layers, drill files, outline), see what is inside a Gerber package.
The versions you will meet
| Name | Also called | What it is | Should you send it? |
|---|---|---|---|
| RS-274-D | Standard Gerber | The original format: coordinates and draw commands only. Aperture shapes and units lived in a separate "wheel" or aperture file that each side read by hand. | No. Ucamco revoked it in 2014. If a tool still offers it, pick RS-274X instead. |
| RS-274X | Extended Gerber, Gerber X1 | Published by Ucamco in 1998. Units, coordinate format and every aperture shape are defined inside the file, so one file is a complete layer image. | Yes. Every manufacturer and every viewer in our ranking reads it. |
| Gerber X2 | RS-274X with attributes | RS-274X plus attributes (first specified in 2014): metadata saying what the file is (top copper, bottom mask, outline), what each pad is, and optionally which net and component each object belongs to. | Yes, where your CAD tool writes it. It draws exactly like X1, so a reader that ignores attributes still gets the right image. |
| Gerber X3 | X2 plus component data for assembly (introduced in 2020): reference designator, position, rotation, footprint, manufacturer and part number per component. | Only if your assembler asks for it; many still want a separate pick-and-place file. |
X2 and X3 don't add new drawing commands, so they are backward compatible: a viewer that doesn't understand attributes simply skips them.
What a Gerber file looks like inside
A Gerber file is ASCII text you can open in any text editor. Here is a short, trimmed example of a top copper layer, in the style KiCad writes:
%TF.GenerationSoftware,KiCad,Pcbnew,8.0*%
%TF.FileFunction,Copper,L1,Top*%
%TF.FilePolarity,Positive*%
%FSLAX46Y46*%
G04 Gerber Fmt 4.6, Leading zero omitted, Abs format (unit mm)*
%MOMM*%
%LPD*%
G01*
G75*
%TA.AperFunction,Conductor*%
%ADD10C,0.250000*%
%TA.AperFunction,SMDPad,CuDef*%
%ADD11R,1.500000X1.000000*%
%TD*%
D10*
%TO.N,GND*%
X100000000Y50000000D02*
X120000000Y50000000D01*
X120000000Y60000000D01*
%TD*%
D11*
%TO.P,R1,1*%
X98500000Y50000000D03*
%TD*%
M02*
Every command ends with *. Commands that set something up for the whole file, or attach an attribute, are wrapped in %…%. Read top to bottom, the file does this:
| Line | What it means |
|---|---|
%TF…*% | File attributes (X2): which program wrote it, which layer this is (Copper,L1,Top), and whether the image is positive or negative. |
%FSLAX46Y46*% | The coordinate format: leading zeros omitted (L), absolute coordinates (A), 4 integer and 6 decimal digits for X and Y. |
G04 …* | A comment. Viewers ignore it. |
%MOMM*% | Units are millimetres (%MOIN*% would be inches). With the format above, X100000000 means 100.000000 mm. |
%LPD*% | Polarity "dark": what follows adds material. %LPC*% ("clear") erases what was drawn before, which is how clearances in a pour are made. |
G01*, G75* | Draw straight lines; allow full arcs when G02/G03 (clockwise and anticlockwise arcs) appear. |
%TA…*% | Aperture attributes (X2): what the next aperture is for, such as a conductor or an SMD pad. |
%ADD10C,0.250000*% | Defines aperture 10 as a circle 0.25 mm across. The standard shapes are circle (C), rectangle (R), obround (O) and regular polygon (P); anything else is built with an aperture macro (%AM…*%). |
%TD*% | Clears the attributes set before it, so they don't carry over to the next objects. |
D10* | Select aperture 10 as the current "pen". |
%TO.N,GND*%, %TO.P,R1,1*% | Object attributes (X2): the net (.N) or the component pin (.P) the next objects belong to. |
X…Y…D02* | Move to a point without drawing. |
X…Y…D01* | Draw from the current point to this one with the current aperture: a track. |
X…Y…D03* | Flash the aperture once at this point: a pad. |
M02* | End of file. |
Two more constructs matter when you look at real files:
- Regions (
G36*…G37*) are filled outlines. Copper pours and large pads should be written as regions. Older or poorly configured exporters "paint" them instead, with thousands of overlapping strokes, which makes huge files that render slowly and can show gaps. - Step and repeat (
%SR…*%) and block apertures (%AB…*%) repeat a piece of the image, mostly for panels.
The attributes that matter most
| Attribute | Example | What it tells a viewer or a fab |
|---|---|---|
.FileFunction | Copper,L2,Inr, Soldermask,Top, Legend,Bot, Profile,NP | Which layer the file is. With it, a viewer places the file correctly whatever its name; without it, the viewer guesses from the filename. |
.FilePolarity | Positive, Negative | Whether drawn areas are material or openings. |
.AperFunction | ComponentPad, ViaPad, Conductor, Profile | What each pad or line is for. |
.N, .P, .C | GND, R1,1, U3 | Net, pin and component of each object, if the exporter writes a netlist into the Gerbers. |
Ucamco's Reference Gerber Viewer displays all X2 attributes and the information on each object. Altium 365 Viewer lists Gerber X2 among its formats. For the other viewers, check our comparison table and each tool's own page.
Drill data is usually not Gerber
Holes are normally sent in Excellon drill files (.drl, .xln), a separate CNC format with its own header for units and number format. The Gerber specification can also describe drill and route data (with file functions such as Plated and NonPlated), and some tools can export it that way, but most packages still use Excellon. When the holes in a viewer don't line up with the pads, the Gerbers are rarely the problem: compare the units and zero format in the drill file's header with the Gerbers. The checklist walks through it.
File names and extensions
The specification recommends the .gbr extension for every Gerber file. Many tools instead use the older "Protel" extensions (.GTL top copper, .GBL bottom copper, .GTS top mask, .GKO keep-out or outline, and so on), which encode the layer in the extension. Both open in any viewer; the difference is that .gbr files rely on X2 attributes or the filename to say what they are. A Gerber job file (.gbrjob) is a different thing: a JSON file that lists the files in the package, the layer order and board data such as thickness.
Getting a clean file out of your CAD tool
- Choose RS-274X, never RS-274-D.
- Turn on X2 attributes if your tool offers them. In KiCad's Plot dialog this is Use extended X2 format, and Include netlist attributes adds the
.N/.P/.Cdata. Our KiCad export guide covers the rest of the settings. - Keep the coordinate precision high. In KiCad, the 4.6, unit mm coordinate format writes 6 decimal places. If your manufacturer publishes its own recommended settings, follow theirs.
- Export pours as regions, not painted strokes, if your tool gives you the choice.
Questions people ask about the format
Can I open a Gerber file in a text editor? Yes. It is plain text, and the first lines tell you a lot: %TF.FileFunction says which layer it is, %MO the units and %FS the coordinate format. To see the board, open it in a viewer: our ranking compares the browser options.
Is Gerber a proprietary format? No. The specification is free to download from Ucamco and anyone can write software that reads or writes it.
What is the latest version of the specification? Ucamco revises it from time to time and numbers each revision by year and month. Check its downloads page for the current one.
Does a Gerber file contain the schematic or the parts list? No. Even X2 with netlist attributes carries only net and pin names on the copper. For the design behind the board, you need the source files: see Gerber files versus design source files.
Are ODB++ and IPC-2581 the same thing? They are alternative formats that put the whole board (layers, drills, netlist, components) in one dataset. Some manufacturers accept them, but Gerber with Excellon drill files is the combination PCB shops most commonly ask for; check your manufacturer's upload page for what it accepts. Altium 365 Viewer opens ODB++; none of the other viewers in our ranking lists it.