How M12 coding works
M12 coding is the key and pin layout inside an M12 circular connector that decides which plug fits which socket. Every M12 connector shares the same 12 mm metric coupling thread, so without coding a Gigabit Ethernet cable could be screwed onto a power socket. The coding adds a key, a ridge on one part and a matching groove on the other, plus a pin pattern unique to each use, so the connector physically refuses the wrong partner.
The codings are lettered and defined in IEC standards. IEC 61076-2-101 covers the original A, B, C and D codings, IEC 61076-2-109 covers X-coded Ethernet, and IEC 61076-2-111 covers the power codings L, S, K and T. The letter is usually printed on the connector body or in the datasheet, and it is the first thing to check when ordering a cable.
Coding also sets the electrical rating. A sensor connector with eight small contacts cannot carry the current of a power connector with four large ones, so the key protects the cable and the equipment as well as the installer.
M12 codings compared
Nine codings cover almost every M12 connector on a machine, vehicle or rugged computer. The ratings below are typical values from the standards and connector datasheets, so always confirm the figures for the exact part.
| Coding | Standard | Pins | Main use | Typical rating |
|---|---|---|---|---|
| A | IEC 61076-2-101 | 3 to 12 | Sensors, actuators, DC power, signals | Around 4 A on 3 to 5 pins |
| B | IEC 61076-2-101 | Usually 5 | PROFIBUS fieldbus | Signal level |
| C | IEC 61076-2-101 | 3 to 6 | Older AC sensors and supplies | Low-current AC |
| D | IEC 61076-2-101 | 4 | 10/100 Mbps Ethernet | 100 Mbit/s |
| X | IEC 61076-2-109 | 8 | Gigabit to 10 Gigabit Ethernet | 10 Gbit/s |
| L | IEC 61076-2-111 | 4 or 5 | DC power, PROFINET devices | 16 A at 63 V DC |
| T | IEC 61076-2-111 | 4 | DC power | 12 A at 63 V DC |
| S | IEC 61076-2-111 | 3 + PE | Single-phase AC power | Up to 630 V AC |
| K | IEC 61076-2-111 | 4 + PE | Three-phase AC power | Up to 630 V AC |
The Ethernet pair is where most mistakes happen. X-coded M12 carries Gigabit and faster links on eight pins, while D coding stops at 100 Mbit/s, and the two do not mate. The four power codings are compared in our guide to M12 power codings.
M12 pinouts by coding
An M12 pinout is the pin assignment for one coding and one use, so there is no single M12 pinout that suits every connector. The standards fix the key and the contact layout, while application guidelines, such as the sensor wiring of IEC 60947-5-2 and the PROFIBUS and PROFINET installation guidelines, fix what each pin carries. Pins are numbered on the mating face, and a socket shows the mirror image of the plug, so check whether a drawing shows the cable end or the device end before wiring.
| Coding and use | Pin assignment and usual wire color | Note |
|---|---|---|
| A-coded, 4-pin sensor | 1: +24 V (brown) · 2: second input or output (white) · 3: 0 V (blue) · 4: switching output (black) | IEC 60947-5-2 sensor wiring; a 5-pin version adds pin 5 (grey) |
| B-coded, 5-pin PROFIBUS | 1: VP, +5 V for termination · 2: A line (green) · 3: DGND · 4: B line (red) · 5: shield | Pins 1 and 3 are not always connected |
| D-coded, 4-pin Ethernet | 1: TX+ (yellow) · 2: RX+ (white) · 3: TX− (orange) · 4: RX− (blue) | The pairs are 1 and 3, and 2 and 4; RJ45 pins 1, 3, 2 and 6 |
| X-coded, 8-pin Ethernet | Pairs on pins 1–2, 3–4, 5–6 and 7–8, one pair in each quarter of the cross-shaped shield | All four pairs carry Gigabit and faster Ethernet |
| L-coded, 5-pin power | 1: 1L+ 24 V (brown) · 2: 2N 0 V (white) · 3: 1N 0 V (blue) · 4: 2L+ 24 V (black) · 5: FE (grey) | Two separate 24 V circuits under the PROFINET guidelines |
The wire colors are the usual ones for each application, not a rule, so check them against the cable datasheet. Our explainers on the B-coded PROFIBUS connector and the L-coded power connector give the full assignments, and the guide to connecting M12 to RJ45 maps the Ethernet pairs onto a standard network plug.
Male, female, plug and socket
Coding and gender are separate choices. A male connector has pins and a female connector has sockets, and either can sit on the cable or on the equipment. By convention the side that supplies power usually has the female sockets, so live contacts sit recessed and cannot be touched or shorted. Ethernet ports on computers and switches are usually female, with male plugs on the cable.
To order a cable, you need four facts: the coding, the pin count, the gender at each end and the cable type. A 4-pin A-coded female plug will not fit a 4-pin D-coded male socket, even though the pin count matches.
How to identify an M12 coding
If the datasheet is not to hand, the face of the connector usually gives the coding away.
-
//
Find the key. A-coded has a single key; B-coded has the key on the opposite side, so it looks like A turned round. D-coded has its key offset for the 4-pin Ethernet layout.
-
//
Look for a cross. X-coded connectors have a cross-shaped shield between four pairs of contacts, which is easy to spot.
-
//
Check the contact size. Power codings use fewer, thicker contacts than signal codings, and S and K include a protective earth contact.
-
//
Count the pins. Four pins with an offset key suggests D; eight pins in a ring with a centre pin suggests A.
-
//
Read the marking. Many connectors carry the coding letter on the body or the moulding. If in doubt, ask for the part number.
M12 coding on industrial computers and switches
Rugged and waterproof computers replace RJ45, USB and barrel power sockets with M12 so that every cable screws into place. On our IP67 computers, Gigabit, 2.5GbE and 10GbE ports are usually X-coded, and many older or train-mounted models use D-coded ports for 100 Mbit/s networks. Serial, USB and digital I/O usually sit on A-coded connectors with 4, 8 or 12 pins.
DC power input varies more than people expect. Manufacturers use A, K, S, L and occasionally B coding for the same 9 to 36 V supply, so the coding on one computer is no guide to the next. Our M12 Ethernet switches follow the same pattern, with X- or D-coded data ports and a separate coded power input. Our guide to M12 waterproof connectors explains why the sealed connector matters at the edge.
Quick answers on M12 coding
M12 coding: common questions
What does M12 mean?
The thread size. M12 refers to the metric 12 mm coupling thread on the connector nut, written M12 × 1. It is not a power or speed rating.
What is the difference between A-coded and D-coded?
Use. A-coded is the general-purpose coding for sensors, signals and low-current power with 3 to 12 pins. D-coded is a 4-pin coding reserved for 10/100 Mbps Ethernet. The keys differ, so they cannot be swapped.
Can you connect two different M12 codings?
Not directly. The keys are designed to stop it. Adaptors exist only where the signals are compatible, such as D-coded to RJ45 or X-coded to RJ45 for Ethernet.
Is there one standard M12 pinout?
No. Each coding has its own pin layout, and the use sets what each pin carries. A 4-pin A-coded sensor and a 4-pin D-coded Ethernet connector are wired quite differently.
Is M12 waterproof?
When mated or capped, usually yes. Most M12 connectors are rated IP67, and IP68 and IP69K versions exist for immersion and high-pressure washdown.
Is M12 coding the same on every brand?
Yes for the interface. The coding and mating face follow the IEC standards, so a compliant A-coded plug from one maker fits an A-coded socket from another. Cable quality and ratings still vary.
We fit M12-connected rugged and waterproof computers as standard, and we specify the matching coded cables for each port before the system ships, so the right plug arrives for every socket.