Chat with us, powered by LiveChat

M12 Pinout Guide: Pin Assignments & Coding (A, B, D, X, S, T, K, L)

Oct 19, 2026 Technical Cable Blog
m12 pinouts

An M12 pinout is the pin-by-pin assignment of signals and wire colors on an M12 circular connector. It depends on two things: the connector’s coding, which sets what it’s used for, and its pin count. For example, on a 4-pin A-coded sensor connector, pin 1 (brown) is +24 V, pin 3 (blue) is 0 V and pin 4 (black) is the signal.

This guide covers the M12 pinout for each common code, with pin numbers, standard wire colors and RJ45 mapping for Ethernet. The pinouts below follow common industry conventions. A device manufacturer can assign pins differently, so always confirm against the datasheet for the sensor, drive or switch you’re connecting to.

How to Read an M12 Pinout

M12 pinout diagrams are almost always drawn looking at the mating face of the connector, the end you plug in. That matters because male and female numbering is mirrored:

  • Male (pins): pins are numbered clockwise when viewed from the mating face.
  • Female (sockets): sockets are numbered counterclockwise, so each socket lines up with the matching pin when the two connectors mate.

The center contact, when there is one, is usually the highest number (pin 5 on a 5-pin, pin 8 on an 8-pin). The keyway or key on the housing is your reference point. Find it first, then count.

Most wiring mistakes on M12 cables come from reading a female diagram as if it were male, or from reading the solder side of a field-wireable connector instead of the mating face.

M12 A-Coded Pinouts

A-coded is the most common M12 code. It’s the standard for sensors, actuators and IO-Link devices, and it’s also used for DeviceNet, CANopen and low-voltage DC power. The wire colors for 3-, 4- and 5-pin sensor cables follow IEC 60947-5-2.

M12 3-Pin and 4-Pin Pinout

A 3-pin M12 uses pins 1, 3 and 4 and skips pin 2. Pin 4 is the switching output for both PNP and NPN sensors. What changes between the two is how the load is wired, not the pinout.

M12 5-Pin Pinout

A 4-pin male connector will usually plug into a 5-pin female socket, because pin 5 is the center contact and the outer four positions match. The reverse doesn’t work: a 5-pin male has a center pin that a 4-pin female can’t accept.

IO-Link Pinout (A-Coded)

Class B ports add a second, separate power supply on pins 2 and 5, usually for actuators. Plugging a Class A device into a Class B port can put 24 V on pin 2, so check both the port and the device before connecting.

M12 8-Pin Pinout

Signal assignments on 8-pin A-coded connectors are set by the device, such as encoders, valve terminals and multi-signal sensors. Some older Gigabit Ethernet devices also use 8-pin A-coded connectors, which is one reason X-coding was introduced.

M12 12-Pin and 17-Pin Pinouts

12-pin and 17-pin A-coded connectors carry many signals in one cable, for valve manifolds and complex sensors, for example. There’s no single universal color code for them. Many manufacturers follow DIN 47100 colors, but not all do, so use the cable manufacturer’s color chart and the device datasheet together.

M12 B-Coded Pinout (Profibus)

B-coding, sometimes called reverse-keyed, is used mainly for Profibus DP.

Profibus cable is a single shielded pair (green and red), so pins 1 and 3 are often used only by termination resistors.

M12 D-Coded Pinout (100 Mbit Ethernet)

D-coded M12 connectors carry 10/100 Mbit Ethernet over two twisted pairs. They’re the standard for PROFINET, EtherNet/IP, EtherCAT and other industrial Ethernet networks running at Fast Ethernet speeds.

One thing trips people up when building an M12-to-RJ45 cable: the pairs don’t sit on neighboring pin numbers. Transmit is on M12 pins 1 and 3, receive is on pins 2 and 4. Keep each pair twisted together all the way to the termination.

M12 X-Coded Pinout (Gigabit and 10 Gbit Ethernet)

X-coded M12 connectors carry 1 Gbit and 10 Gbit Ethernet over four twisted pairs (Cat6A). Inside, an X-shaped shield separates the four pairs to control crosstalk, which is what makes 10 Gbit possible in a connector this small. X-coding is defined in IEC 61076-2-109.

Note that pins 7 and 8 are reversed compared with the other pairs: pin 7 is the negative side of pair C, and pin 8 is the positive. Getting this wrong is the most common X-coded wiring error. The cable may still pass a basic continuity check, but the link can fail or fall back to a lower speed.

What Does M12 Coding Mean?

M12 coding is the mechanical keying on the connector housing and insert: a key and keyway in a set position for each code. It stops two incompatible connectors from mating, so a 24 V sensor cable can’t be plugged into an Ethernet port, or an AC power cable into a DC device.

Standard M12 connectors use an M12×1 threaded coupling nut, so codes can look nearly identical at a glance. Check the code on the part number or the face of the insert, not just the pin count. For example, A-coded and D-coded 4-pin connectors both have four pins, but they won’t mate with each other.

Signal and data codes A, B, C and D are defined in IEC 61076-2-101. X-coding is in IEC 61076-2-109, and the power codes are in IEC 61076-2-111. C-coding (AC signals) is rarely used.

M12 A-Coded vs. D-Coded vs. X-Coded

The short version: A-coded is for sensors and devices, D-coded is for standard industrial Ethernet, and X-coded is for anything that needs Gigabit speeds, such as machine vision cameras and network backbones.

M12 Power Codes: S, T, K and L

Power codes are built for higher currents than signal codes. They’re used to power motors, drives and devices through daisy-chained distribution. AC codes are typically rated up to 630 V and DC codes up to 63 V, with current ratings in the 12–16 A range depending on the manufacturer, contact design and wire gauge. Always use the rating from the connector datasheet, not a generic chart. Pin assignments for power codes also vary by system (PROFINET power over L-code, for example, has its own convention), so confirm them against the device documentation. There’s also an M-coded variant for AC with additional contacts and a Y-coded hybrid that carries power and data in one connector.

How to Choose the Right M12 Code and Pinout

  1. Start with the device. The sensor, drive, I/O block or switch sets the code and pinout. Copy it from the datasheet.
  2. Match the signal type. Discrete or IO-Link signals mean A-coded. 100 Mbit Ethernet means D-coded. Gigabit or above means X-coded. Power distribution means S, T, K or L.
  3. Confirm gender at each end. Devices and panel receptacles usually take one gender. The cable end takes the other.
  4. Pick the cable. Match the conductor count, gauge and shielding to the code and current, and the jacket to the environment: PVC for general use, PUR for oil, abrasion and drag-chain motion.
  5. Write the pinout on the drawing. A pin-to-pin wiring table on the cable drawing is the clearest way to avoid a mis-wired assembly. Include connector part numbers, code, gender, straight or right-angle, wire colors, shield termination, length and tolerance.

Technical Cable Applications has built custom cable assemblies to customer drawings since 2002, out of Auburn, WA. We build M12 cable assemblies in A-, B-, D- and X-coded versions for sensors, fieldbus and industrial Ethernet, in shielded and unshielded constructions with PVC, PUR or FRNC overmolded jackets. We’re ISO 9001:2015 and UL certified for wiring harness components, and build to IPC/WHMA-A-620 Revision E standards. Every assembly is inspected for continuity and against your drawing before it ships.

TCA

Technical Cable Applications

Technical Cable Applications was founded in 2002 in Auburn, WA. Since then, we have grown to serve customers all over the United States, North America, and internationally. Our staff has expanded tenfold since our original startup along with our facility’s real estate, reflecting our commitment to growth and excellence.