M12 Connector Pinout: All Pin Configurations

M12 connector pinout diagrams and wiring for every coding and pin count: 4-pin A, 5-pin A, 4-pin D, 8-pin X and more, with standard wire colors.

M12 Connector Pinout: All Pin Configurations

On this page

Looking to interactively explore every pinout — switch coding, pin count and male/female views, and highlight contacts? Use the Pinout Viewer tool. This page explains how M12 pinouts work and shows the most common configurations.

Quick Answer

An M12 connector pinout defines which signal sits on each numbered contact. The pinout depends on both the coding and the pin count, so a 4-pin A-coded sensor connector and a 4-pin D-coded Ethernet connector are wired completely differently. Pin numbering is fixed, but the male and female versions are mirror images of each other, so always confirm the coding, the pin count and the gender before wiring.

How to Read a Pinout

An M12 pinout diagram shows the mating face of the connector — the end that plugs in — with each contact numbered in a fixed sequence. To read it correctly, work through three checks in order.

First, confirm the coding and pin count, because together they determine the entire assignment. The same pin number means different things on different codings: pin 1 on an A-coded sensor connector is a power contact, while the contacts on a D-coded connector carry Ethernet pairs. There is no single "M12 pinout" — there is a pinout for each coding and pin-count combination, which is why you should never assume one connector's layout applies to another.

Second, confirm whether you are looking at the male or the female face. A male connector carries pins and the female carries sockets, and the two are mirror images: a contact at the top-left of the male plug appears at the top-right of the female socket it mates with. This mirroring is the single most common source of wiring errors, so never assume — check which face the diagram represents. The interactive diagrams below show the male view, and the Pinout Viewer tool lets you flip between male and female so you can match whichever end you are wiring.

Third, map each number to its signal using the pinout table. Each numbered contact has a defined signal and, for many connectors, a standard wire color, so the table tells you exactly what to connect where. Read the diagram and table together: hover a contact on the diagrams below and it highlights in the table, which makes it easy to trace a single conductor end to end. Remember that the IP rating only takes effect once the connector is mated and tightened, so a correctly wired but loose connector is neither sealed nor reliable.

Below are the most common M12 connector pinouts, each shown as an interactive diagram and table — hover over a contact to highlight it in both.

Male, Female and Panel vs Cable

Two physical distinctions shape how you apply any M12 pinout: gender and mounting.

Gender refers to the contacts. A male connector has pins; a female has sockets. Because a plug and the socket it mates with face each other, their layouts are mirror images: the numbering runs the same way, but a contact on the left of the male sits on the right of the female. The signal on a given pin number is identical on both — pin 1 is electrically pin 1 either way — but its physical position flips. When you terminate a connector, always wire to the diagram for the gender you are actually holding.

Mounting adds a second viewpoint. A cable connector on a lead and a panel connector mounted on a device share the pinout for a given coding and pin count, but you approach them from opposite sides as you work. Diagrams are conventionally drawn looking at the mating face, so for a panel socket you are seeing the face the cable plugs into, and for a cable plug you are seeing the face that enters the socket. Keeping straight which face you are looking at, together with the gender, removes nearly all of the confusion that surrounds M12 wiring — and it is exactly what the male/female switch in the Pinout Viewer is there to help with.

4-Pin A-Coded

The 4-pin A-coded connector is the most common M12 pinout of all. It is the standard interface for three- and four-wire sensors and simple actuators, and it appears on more devices than any other M12 configuration. In the usual convention, pin 1 is the positive supply (brown) and pin 3 is the negative supply (blue), while pins 2 and 4 carry signals — most often a switching output on pin 4 (black).

A three-wire sensor uses the supply pair plus one switching output, leaving the fourth contact unused or available for a second output; a four-wire sensor uses all four. The output may be PNP or NPN depending on the device, so the contact numbering tells you where the output sits, but the datasheet tells you its electrical type. Because this layout is so widely standardised, off-the-shelf cordsets are stocked everywhere and wiring is fast and predictable.

Because the 4-pin A-coded layout is so common, it is also available in the widest choice of mechanical formats — straight and right-angled bodies, a range of cordset lengths, and both pre-moulded and field-wireable versions — all sharing the same pinout. That means you can pick the mechanical form that fits the installation without relearning the wiring. When in doubt about which contact carries the output on a particular device, hover the pins in the diagram and cross-check against the datasheet rather than assuming.

4-Pin A-Coded · male view
1L+2IN3L-4OUT
PinSignalWire ColorFunction
1L+Brown+24V DC
2INWhiteInput Signal
3L-Blue0V / Ground
4OUTBlackSignal Output

5-Pin A-Coded

The 5-pin A-coded connector adds a fifth contact to the 4-pin layout. That extra pin is used for an additional signal, a second output, an analogue value, or a functional earth and shield, which makes the 5-pin version the choice for devices that combine I/O with diagnostics or need a screen connection. The supply convention follows the 4-pin layout — brown and blue for the supply pair — with pin 5 (grey) carrying the additional function.

Because the first four contacts mirror the 4-pin arrangement, a 5-pin A-coded connector is easy to wire for anyone already familiar with the 4-pin layout; only the role of pin 5 needs to be checked against the device. As always, confirm whether pin 5 is a signal or a functional earth before connecting it. For the full assignment, the B-coded PROFIBUS variant and the color code, see the 5-pin pinout guide.

5-Pin A-Coded · male view
1L+2IN3L-4OUT5FE
PinSignalWire ColorFunction
1L+Brown+24V DC
2INWhiteInput Signal
3L-Blue0V / Ground
4OUTBlackSignal Output
5FEGrayFunctional Earth / Shield

4-Pin D-Coded

The 4-pin D-coded connector is the M12 pinout for 100 Mbit industrial Ethernet, including PROFINET and EtherNet/IP. Its four contacts carry the two pairs of 100BASE-TX Ethernet — one transmit pair and one receive pair — in a sealed, locking connector suited to the factory floor.

The assignment is completely different from the 4-pin A-coded sensor connector, even though both have four contacts. There is no power on a standard 4-pin D-coded connector; it is purely a data interface, so devices that need both power and network use a separate power connector. When wiring D-coded Ethernet, the pairs must be kept together and the cable shield carried through to maintain signal integrity. If a device specifies PROFINET or EtherNet/IP at 100 Mbit, this is the pinout it expects.

Because only two pairs are used, the 4-pin D-coded connector is dedicated to 100 Mbit and cannot be pushed to Gigabit speeds — that requires the four pairs of the X-coded connector below. For new installations that may need to scale, it is worth confirming early whether 100 Mbit will remain sufficient, because the connector choice and cabling differ between the two. Use shielded, suitably rated cable and keep each pair twisted right up to the contacts for reliable links.

4-Pin D-Coded · male view
1TX+2RX+3TX-4RX-
PinSignalWire ColorFunction
1TX+YellowTransmit Data +
2RX+WhiteReceive Data +
3TX-OrangeTransmit Data -
4RX-BlueReceive Data -

8-Pin X-Coded

The 8-pin X-coded connector is the M12 pinout for high-speed Ethernet up to 10 Gigabit, and for protocols such as EtherCAT. Its eight contacts are arranged as four pairs, with internal shielding between the pairs that allows the high data rates while controlling crosstalk in electrically noisy environments.

Reaching the rated speed depends on the whole link, not just the connector: the cable must be properly shielded and category-rated, and the four-pair shielding must be carried end to end. Pairing an X-coded connector with under-specified cable will not deliver Gigabit or 10 Gigabit performance, so the connector and cable should be specified together as a matched assembly. Where a network has outgrown the 100 Mbit of D-coding, X-coding is the upgrade path on the same M12 form factor.

Because all eight contacts are in use as four pairs, the X-coded pinout leaves no spare contact for power; like D-coding, it is a data-only interface, and power is delivered separately where a device needs both. When terminating an X-coded connector, keep each pair twisted to the contact and preserve the inter-pair shield, as both are essential to the high-frequency performance the coding exists to provide.

8-Pin X-Coded · male view
1DA+2DA-3DB+4DC+5DC-6DB-7DD+8DD-
PinSignalWire ColorFunction
1DA+White/OrangePair A Data +
2DA-OrangePair A Data -
3DB+White/GreenPair B Data +
4DC+White/BluePair C Data +
5DC-BluePair C Data -
6DB-GreenPair B Data -
7DD+White/BrownPair D Data +
8DD-BrownPair D Data -

Other Configurations

Several more M12 pinouts cover specific needs. The 3-pin A-coded connector is a compact layout for simple two- and three-wire sensors where four contacts are not needed, saving space on small devices. The 8-pin A-coded connector provides multiple signal channels for multi-function sensors and dense I/O, packing eight contacts into the same 12 mm body. The 5-pin B-coded connector is the PROFIBUS fieldbus pinout, with its own keying and a contact assignment distinct from the A-coded 5-pin, so the two cannot be confused or cross-mated.

Power codings (C, T and K) have their own pinouts again, arranged for higher-current conductors rather than signals. You can view the exact diagram and table for these and every other configuration, and switch between male and female views, in the Pinout Viewer tool. For how the codings themselves differ, see the M12 connector types guide.

Wire Colors

Standardised wire colors make M12 cordsets quick and safe to wire. For A-coded connectors the widely used color code is pin 1 brown, pin 2 white, pin 3 blue, pin 4 black, and pin 5 grey on 5-pin versions. The brown-and-blue pair for the supply mirrors common DC power conventions, which makes power easy to identify at a glance and reduces wiring errors in the field.

These colors apply to A-coded signal and I/O connectors. Ethernet codings (D and X) and the power codings (C, T and K) use their own conventions suited to twisted pairs or to higher-current conductors, so the A-coded color code should not be assumed for them — an Ethernet cordset, for example, follows pair colors rather than the brown/blue/black/white sequence. In every case, the authoritative reference is the pinout table for the specific connector, shown alongside each diagram above and in the Pinout Viewer. When you wire a field-attachable connector, match conductor colors to the table contact by contact, and verify continuity with a meter before energising. For the standard color code across every coding in one place, see the M12 connector wiring diagram.

M12 Pinout Standards

M12 pinouts are not arbitrary — they are defined by the IEC 61076-2-101 family of standards, with individual parts covering the different codings. That standardisation is what makes the ecosystem work: when you specify a "4-pin A-coded" or "8-pin X-coded" connector, the pin assignment is the same whoever makes it, so a cordset from one supplier mates and wires correctly with a device from another.

Standardisation also means the pinout travels with the coding and pin count, independent of the housing style. A panel-mount socket, a field-wireable plug and a pre-moulded cordset of the same coding and pin count all share the pinout, even though their mechanics differ. The practical takeaway is that two pieces of information — coding and pin count — are usually enough to identify the pinout, and the device datasheet is the final authority where a device assigns contacts to a specific purpose within that standard layout.

Common Pinout Mistakes

A handful of recurring errors cause most M12 wiring problems, and all are easy to avoid once you know them.

The first is the male/female mix-up: wiring to a male diagram when you are actually terminating the female end, or vice versa. Because the two faces are mirror images, this reverses the contact positions and produces a link that does not work. Always confirm the gender of the face you are wiring.

The second is assuming a pin number means the same thing across codings. Pin 1 is a supply contact on an A-coded connector but part of an Ethernet pair on a D-coded one. Match the diagram to the actual coding, not to memory.

The third is carrying the A-coded color code onto a non-A-coded connector. Ethernet and power codings use different conventions, so always read the table for the specific part rather than assuming brown is always positive supply.

The fourth is neglecting the shield and functional earth, especially on Ethernet and screened sensor connections, where a missing shield connection degrades signal integrity. And the fifth is skipping a continuity check: a quick meter test against the pinout table catches a transposed or open contact before it reaches the machine.

Finding Any M12 Pinout

The fastest way to confirm a pinout is to use the interactive Pinout Viewer. It covers every coding and pin count in our data, draws the diagram programmatically, lets you switch between male and female views, and highlights a contact across both the diagram and the table when you hover or tap it. You can also link straight to a specific configuration, which is handy when sharing a pinout with a colleague.

If you are still selecting a connector rather than wiring one, start from the connector selector, which filters the full range by application, protocol, pin count and IP rating, and lets you request a quote on any result. For background on the M12 form factor and its codings, see the what is an M12 connector and M12 connector types guides.

For configuration-specific pinouts, see the dedicated 4-pin, 5-pin, 8-pin and 12-pin guides, the CAN bus pinout for CANopen and DeviceNet, and the consolidated wiring diagram.

Frequently asked questions

What is the standard M12 4-pin pinout?
For a 4-pin A-coded M12 connector the common assignment is pin 1 = L+ (brown), pin 2 = signal (white), pin 3 = L- (blue) and pin 4 = signal (black). Always confirm against the device datasheet and the diagram, as the exact use of each contact depends on the device.
Are male and female M12 pinouts the same?
The pin numbering is the same, but the physical layout is mirrored. A male connector and the female it mates with are mirror images, so a contact at one position on the plug appears on the opposite side of the socket. Always check whether a diagram shows the male or female face.
What are the wire colors for an M12 connector?
A-coded M12 connectors follow a standard color code: pin 1 brown, pin 2 white, pin 3 blue, pin 4 black, and pin 5 grey on 5-pin versions. Other codings, especially Ethernet and power types, use different conventions, so verify against the specific connector.
How do I read an M12 connector pinout diagram?
Read the diagram as the view of the connector's mating face, with contacts numbered in a fixed order. First confirm the coding and pin count, then whether the view is male (pins) or female (sockets), because the two are mirrored. The number on each contact maps to the signal in the pinout table.
Is the pinout the same for all M12 connectors?
No. The pinout depends on both the coding and the pin count. A 4-pin A-coded sensor connector and a 4-pin D-coded Ethernet connector have completely different pin assignments, even though both have four contacts.

Need the right M12 connector wired your way?

Find connectors by coding, pin count and IP rating, or send us your pinout requirements for a quote.