fj laboratories

Musings, deliberations, and end results.

Understanding Gerbers

Felix Jen – 30 June 2022 – 15 min read


When we share images with our friends or to some newly-developed social media platform, we send around files like JPEGs, PNGs, and (if you’re exceptionally anal about quality) 32-bit TIFFs. When we share embarrassing videos of our friends or law school graduation videos with our parents, we send out MP4s, MKVs, and, AVIs. When we share PCB production instructions with our manufacturers, we send out “Gerbers”. Let’s talk about “Gerbers” as they are known in PCB production.

PCB picture

PCB Production Skim

To understand the nature of the Gerber, we must first take a cursory understanding of the PCB production process.

Each PCB is produced in a “layer-based” process. Typical 2-layer PCBs begin like a grilled cheese sandwich. Two sheets of pure copper are the slices of bread and the cheese is the “substrate”. Effectively, we create a sandwich with substrate between two layers of copper—one on the top and one on the bottom. Next, portions of the copper from each side are removed using (primarily) chemical processes, forming the traces and planes the PCB engineer laid out. This creates our top and bottom layers we see in our EDA when designing.1

Next, to protect the bare copper from short circuits, the environment, and inevitable human fallibility, a protective layer of resin called “soldermask” is applied to the top and bottom layers. Soldermask serves a few additional purposes. In additional to protecting the copper layer, it also serves to prevent solder from adhering and helps to prevent bridges when soldering thin-pitched components present in modern day electronics. It also serves to create a barrier for the next stage of the process—surface treatment.

Once the soldermask is applied, we are left with some areas covered with soldermask resin and some areas still bare copper. Copper oxidizes quickly when exposed to a humid and salty environment, so we must coat the copper to prevent damage. This stage is called surface treatment and involves the application of an inert metal to the outer layers of exposed copper—the parts the soldermask did not cover.

Lastly, to achieve a bare PCB, a silkscreen layer is typically applied. This layer contains visual diagrams for component locations and text to designate what components go where. This can either be printed or actually “silkscreened” on for larger productions. Once this silkscreen is applied, we are left with what can be considered a finished “bare” PCB.

PCB with Surface Treatment

Once a bare PCB is finished, it is often sent for assembly, which involves the use of another layer, the solder paste layer. Solder paste is a viscous liquid which contains balls of solder. When a PCB goes through “reflow”, this solder paste is liquefied and becomes molten solder to hold components down and form electrical connections. Areas which have surface mount components typically have a solder mask layer applied.

With these processes, we typically have a complete assembled PCB. More advanced specialized layers and functions will be discussed later on in this post.

The PCB Sandwich

Having run through these production processes, we are left with what is essentially a stack of layers from the top of the PCB to the very bottom. Aptly, this stack of layers is known as the “PCB Layer Stack” or the “stackup.” In our typical 2-layer PCB, we end up with the following layer stack:

Layer Purpose
Top Solder Paste Assembly
Top Silk Silkscreen
Top Soldermask Solder Masking
Top Copper Electrical Connections
Substrate Base Substrate
Bottom Copper Electrical Connections
Bottom Soldermask Solder Masking
Bottom Silk Silkscreen
Bottom Solder Paste Assembly

To effectively manufacture each one of these layers then, a PCB manufacturer (fab) must have the data which corresponds to the contents of every single layer. This is where Gerbers come in.

PCB Stackup

Photo by AllPCB on AllPCB

The Gerber File

A Gerber file is, at its inception, an ASCII-based vector representation of PCB design data, optimized for data transfer between stakeholders in the production process. In some sense, one may think about them like any other type of text-based vector file format like an SVG. A little bit of trivia, the Gerber file format was named after Joseph Gerber who fled Austria during WWII, later going on to pioneer photoplotting for PCB fabrication.2

In modern days, the Gerber specification has evolved considerably since its initial inception. The original Gerber specification, RS-274-D, is still the most ubiquitous and easy-to-process format for Gerbers available, and is often colloquially referred to as the “standard Gerber.” The second iteration, RS-274X provided some additional extensions to the Gerber functionality, and is known as the “Extended Gerber.” In recent years, Ucamco—the owner of the open Gerber format—has released Gerber X2 with many more features to help manufacturers better understand provided Gerber files in complex layer stacks. In 2022, Ucamco developed additional modifications, known as Gerber X3 to address lingering issues with Gerber X2.

Gerber X2 and RS-274X still remain the most relevant Gerber standards to this day with older fabs preferring RS-274X and modernized manufacturers happily accepting X2. This blog post mostly will discuss X2, but differences to RS-274X will be discussed when relevant and in the comparison sections. Some mentions may be made to X3, the newest standard, but widespread adoption will likely take many years if not a decade as designers and manufacturers slowly migrate. Of note, on May 30, 2014, Ucamco has declared the Standard Gerber to be obsolete and any designers or manufacturers still utilizing the Standard Gerber should immediately move to Extended Gerbers.

The File Structure

A Gerber layer is a 2D vector image format with the image defined by overlapping graphical objects; this will make more sense later as we discuss the nitty gritty of the format. A single Gerber file will represent one single image, and, in effect, one layer of a stackup. The Gerber file is designed to be a complete representation of that layer and no additional files should be needed to reproduce that singular layer.

The Gerber format when viewed in a text editor is a stream of commands. These commands are responsible for creating graphical “apertures” (consider these as basic shapes) which are added together to create an image file. For example, if you want to made a house that a first grader drew in Gerber, the commands would consist of a square aperture and a triangle aperture. These apertures can be in either black or white. Additional commands are used to add metadata to the apertures (or to the file itself in X2).

Stack of Books

An example of a Gerber which generates a circle of 1.5 mm centered on the origin is:3



Apertures in the Gerber format can be thought of as the basic building blocks of the final image. Effectively, they are the “pixel” of the Gerber file. Apertures can be “flashed” (replicated), or “drawn” (repeated along a path). The four standard apertures that are the basis of the format are the Circle, Rectangle, Obround, and Polygon.4 Circles and rectangles are fairly self explanatory, whereas the Obround and Polygon require a bit more context. An Obround consists of two semi-circles connected by a line segment. This creates what is similar to an oblong pill shape. The polygon creates a regular polygon of N vertices with a D outer diameter of the circle circumscribing the regular polygon. Each of these standard apertures may have a round hole in the center of them.

hexagon tiling

Photo by Donny Jiang on Unsplash

The following syntax of apertures covers the four standard ones:5

Circle: 'c' ',' diameter 'X' hole_diameter
Circle Diameter 0.5 w/ Hole of 0.25: %ADD10C, 0.5X0.25*%

Rectangle: 'R' ',' x_size 'X y_size 'X' hole_diameter
Rect. of X = 0.044 and Y=0.025: %ADD23R, 0.044X0.025*%

Obround: 'O' ',' x_size 'X' y_size' 'X' hole_diameter

Polygon: 'P' ',' outer_diameter 'X' vertices 'X' rotation 'X' hole_diameter
Hexagon of size .04 rotated 15 degrees clockwise: %ADD17P, .04X6X15*%

While these are the standard apertures, additional Aperture Macros (AMs) can be defined before usage. These AMs are then added to the aperture library and can be used like other apertures. These templates can be of any shapes and multiple primitive shapes can be combined to much more complex geometry. Discussion on the exact nature of creating the Aperture Macro is beyond the scope of this deep dive, but more information can be found under § 4.5 - Aperture Macro (AM) of Rev. 2022.02 of the Gerber X2 standard.

Draws, Arcs, Flashes, Regions

a o Now that we have a basic idea of the building blocks known as apertures, we can discuss how they are used to form images. Apertures are directly used in three main ways, the draw, arc, and flash.

The Draw

A draw takes a single, closed, Circle aperture and drags it along a straight line. This creates a line with a thickness of the diameter of the circle and with rounded points.

Example of Draw

The Arc

An arc takes a single, closed, Circle aperture and drags it along a circular plot. This creates an arc segment with a thickness of the diameter of the circle and with rounded points.

Example of Arc

The Flash

A flash takes an existing aperture and stamps it on the image plane. This effectively just repeats the aperture defined at specified coordinates and is the proper way to create “pads.”

The Region

The region is the most complicated of the bunch. A region is defined by its “contour.” A contour is a sequence of connected linear or circular segments6. These segments are specified, if linear, by the direction and distance they need to travel, and if circular, by their start point and radius. Contours can be completely solid or “cut in” through the use of closing them off naturally or through polarity of multiple contours (outside the scope). We’ll return to polarity later.

Example of a contour created by overlapping multiple regions of different polarities


Operations are the commands used to perform the things just described. Gerbers have 3 operations, D01, D02, D03. D01 creates a line plot (for draws) from the current point to the point specified in the command. For example, X200Y200D02* would move from the current point, wherever it is, to point (200,200). D02 executes the move. For example, X100Y100D01* would move the current point to (100,100). D03 creates a flash of the current aperture at the specified point. X300Y-400D03* would flash the current aperture at (300,-400).


A Gerber file consists purely of black (“dark” in Gerber terms) and clear. The “image plane” (the blank starting image) always starts as clear. A dark object will get superimposed onto this clear plane, creating an image. A clear object can then be put on top to remove portions. Another dark image can be overlaid again to add back portions, so on and so forth. This method can effectively be used to create very complex shapes that a simple aperture or primitive could not. For example, if one wishes to create a rectangle with two holes inside of it, one could first create a dark rectangle on the image plane, followed by two clear circles within that rectangle. Should one desire another rectangle inside one of those cut out circles, one could add a dark rectangle.

Demonstration of overlapping polarity of various shapes


One of the nicest updates in Gerber X2 is the extensions of attributes. Attributes are “meta” properties associated with the Gerber file itself (File Attributes), apertures (Aperture Attributes), or objects (Object Attributes). These attributes themselves do not define any part of the image at all and a pure Gerber reader can entirely ignore all attributes without issue. Attributes are effectively information labels attached to things.

Importance in Modern Manufacturing

Ucamco was cognizant that as PCB design and layout got more and more complicated, manufacturers would have a hard time understanding and processing Gerber files. Each Gerber file stood for one layer of the PCB and only one layer of the PCB. Therefore, in a multi-layer PCB or even a single-layer PCB with a stackup, multiple Gerber files would need be provided. In the stackup above, we already have 8 Gerber files which need to be provided. With no way of embedding the purpose of each Gerber file in the RS-274X or RS-274-D standards, PCB designers were left to find some way to communicate the purpose of each layer to the fab. Creative designers would create filenames such as top_copper.gbr or bottom_soldermask.gbr for their files so fabs could understand the purpose of the files given. Alternatively, some would change the file extension to be or gerber.bmask to help differentiate.

This solution of file naming worked in the short run and for simple PCB designs of two layers. However, more complexity arose in the age of multi-layer PCBs, with some consisting of up to 128 individual copper layers all sandwiched together. With this many layers, any real naming scheme became impractical and difficult for both the manufacturer and the designers to keep track of, especially in an automated fashion. Existing Gerber viewers could not easily cope with the variety of creative solutions that humans came up with in naming (“What is layer.23gbr?” “Is l24.gbr Layer 24?”) and often required hours of manual intervention.

Complex circuit board

Gerber X2 solved this problem by creating File Attributes. File Attributes allow EDA software to automatically and quickly label each file for its intended purpose and position in the stackup without having to resort to unusual naming schemes. As well, even if the files were named asdklj.gbr, the attribute would still be able to tell the Gerber viewer that it was supposed to be the soldermask for the top layer as long as %TF.FileFunction,Soldermask,Top*% is present in the first few lines.

This advancement overall solved significant communication hurdles from CAD to CAM (Design to Manufacturing) in modern complex designs and was one of the most important advancements in the format recently. Furthermore, because attributes are silent additional lines of metadata, X2 files are fully backwards compatible with existing Gerber systems which would simply ignore the extraneous lines.

The Gerber Package

Now that we have a fairly robust understanding of a single Gerber file, it becomes apt to discuss the Gerber “package” as I’ve come to know it. The Gerber “package” consists of all Gerber files in the layer stackup as well as typically the “drill file.” We’ll take a quick detour from Gerbers talk about the “drill file,” “NC Drill,” “Excellon file,” or a host of other names.

The Excellon File

I’ll primarily call this file the Excellon file or the drill file in this blog post since I feel like those two names describe it best. The Excellon file is a file which represent all the holes to be drilled on the PCB. This step usually occurs before the soldermask stage but after etching of the traces.

The Excellon Drill Format is a subset of the Gerber RS-274-D instruction set and hence why the drill file is frequently known as the Excellon file. This file format has not received the same love and attention that the Gerber format has, and much of it still relates back to the dated RS-274-D standard. The file begins with a header which specifies important information such as the coordinate system, units, and number of leading zeroes in the format (00020 vs 020). The file then specifies the appropriate drill bit size for the next set of drilling operations. Much like the Gerber file, an operation is used to change the current point (where the bit is located) and a series of commands are then given to perform the required drilling operations. Then, an end instruction is sent and we begin with a tool change to a new bit size. This process is repeated until all needed holes are drilled.

Drill bits

The Specialized Gerbers

While we have discussed the traditional stackup Gerbers earlier, it is important to remember that Gerber files are merely vector images. That means, they can be used for a variety of specialized purposes besides merely providing the stackup layers.

The most common non-layer Gerber you will see are the profile, plated, and nonplated Gerbers. As the name implies, the profile Gerber specifies the outer profile of the PCB. As well, the profile layer may sometimes show any interior slots or cuts which need to be made. The profile layer is frequently used in the manufacturing process to check whether any traces have contacted the outer edges or internal slots and may be cut during the routing and shaping process. The plated and nonplated Gerbers define holes on the PCB which may require plating or which should not be plated.

Another very important specialized Gerber is the FabricationDrawing Gerber. This purely informational Gerber file is used to aid the PCB manufacturer by providing additional notes or call-outs of critical areas, orientation of confusing components such as electrolytic capacitors, or even panelization instructions like mousebite locations. As manufacturers understand that such a Gerber is purely informational, multiple types of these Gerbers are often provided when such information is helpful or necessary.

Architectural blueprint drawing

Photo by Sven Mieke on Unsplash


Gerber files, like all things in the real world, must maintain a finite precision. For Gerbers, this is defined by the number of significant digits in the integer portion and the decimal portion. For example, a precision of 3-integer 4-decimal may give you a result of 125.3745 in the coordinates while a higher precision of 5-integer 6-decimal would give you a result of 00125.374498. Typically, it’s recommended to keep at least a minimum of 3-integer 3-decimal when working with PCBs with copper regions that are frequently susceptible to “aliasing” with lower precisions. Ultimately, the tradeoff with higher precision is a significant increase to file size with large packages involving tens of layers. However, with modern storage and compute power, one would do well to keep precision to the highest allowed in the EDA, unless otherwise instructed by your manufacturer.


The common Gerber file is a versatile tool for the world of PCB production. We’ve taken a deep dive into the technical workings of a standard Gerber file and discussed how the improvements in X2 have improved manufacturing efficiency and reduced confusion in the CAD-CAM pipeline. The simple format, consisting of only 27 commands total (some of which are discussed here) is often considered the backbone of the electronics industry.

“Gerber is the only data format, as far as I know, that has dropped enough historical burdens to remain lively, based on current practice deliberately surveyed. The result is, of course, a specification easy to read and to implement correctly.”

— Frog Chen7

Special thanks to Maker Keyboards for providing edits.

  1. Note a few very important steps are skipped in this brief overview, notably the panel plating stage. Additionally internal layer pre-preg etching stages and lamination are omitted. [Back]

  2. Ucamco, The Gerber Layout Format Specification, Preface, 2022.02, 7 (2022) [Back]

  3. Id. at 2.2, 11. [Back]

  4. Id[Back]

  5. Id. at 4.4, 50–55. [Back]

  6. Id. at 4.10.3, 90. [Back]

  7. Ucamco[Back]