When selecting M12 connectors for an industrial Ethernet network, the choice between X-code and D-code is critical. While they look similar, they are designed for different data speeds and are not interchangeable. Choosing the wrong one can lead to project delays, incorrect parts, and equipment that simply won't connect.
This article clarifies the practical differences between M12 X-code and D-code connectors. We'll cover their performance, pinouts, and common applications so you can confidently select the right cable for your PLC, switch, or machine vision system.
TL;DR: The Quick Answer
- M12 D-Code: Use for 10/100 Mbps Ethernet. It has 4 pins and is the standard for most industrial automation systems using protocols like Profinet and EtherNet/IP.
- M12 X-Code: Use for high-speed Gigabit Ethernet up to 10 Gbps. It has 8 pins and is required for applications like high-resolution machine vision and factory network backbones.
- Key Rule: They are physically incompatible. A D-code cable will not plug into an X-code port, and vice-versa. Always check the port on your device first.
The Core Difference: Data Speed and Pin Count
The "coding" or "keying" on an M12 connector refers to the physical shape of the insulator and pin layout. This design prevents you from connecting incompatible connectors, protecting your equipment from electrical damage and ensuring signal integrity.

M12 D-Code: The 100 Mbps Workhorse
The M12 D-code connector uses a 4-pin configuration. It's designed to support Category 5e (Cat5e) standards for 10/100 Mbps Fast Ethernet. For years, this has been the go-to connector for industrial automation, providing reliable data transfer for the majority of PLCs, HMIs, sensors, and remote I/O modules.
M12 X-Code: The High-Speed Gigabit Option
The M12 X-code connector features an 8-pin layout with special shielding between the twisted pairs. This design minimizes crosstalk and allows it to support Category 6A (Cat6A) performance for high-speed data transmission up to 10 Gbps. This makes it the standard for any application demanding more bandwidth than 100 Mbps can provide.
Comparison Table: M12 D-Code vs. X-Code at a Glance
| Feature | M12 D-Code | M12 X-Code |
|---|---|---|
| Pin Count | 4-Pin | 8-Pin |
| Maximum Data Rate | 100 Mbps | 10 Gbps |
| Typical Ethernet | 10BASE-T / 100BASE-TX, Cat5e | 1000BASE-T / 10GBASE-T, Cat6A |
| Internal Arrangement | 4 pins arranged in a square pattern. | 8 pins with X-shaped shielding between pairs. |
| Common Protocols | Profinet, EtherNet/IP, EtherCAT | High-speed EtherNet/IP, TCP/IP, machine vision |
| Primary Use Cases | PLCs, sensors, actuators, HMIs, I/O blocks | High-resolution cameras, network backbones, IIoT |
When to Specify M12 D-Code (100 Mbps)
For a large portion of industrial equipment, 100 Mbps is more than sufficient. You should specify an M12 D-code 4-pin cable assembly for:
- Connecting to standard PLCs and controllers.
- Wiring distributed I/O blocks and valve terminals.
- Networking HMIs and operator panels.
- Most sensor and actuator applications running on an Ethernet protocol.
- Systems where the device port or manual explicitly calls for a D-coded M12 connector.
Using an over-specified X-code cable in a D-code system offers no performance benefit and results in unnecessary cost.
When to Upgrade to M12 X-Code (Up to 10 Gbps)
The demand for higher bandwidth is growing, especially in data-intensive applications. You will need an M12 X-code 8-pin high-speed cable assembly when:
- Connecting High-Resolution Machine Vision Cameras: These cameras generate large amounts of data that require gigabit speeds for real-time processing.
- Building a Factory Network Backbone: Connecting switches or linking different production cells often requires a high-speed backbone to prevent data bottlenecks.
- High-Speed Data Acquisition: Transferring large logs or diagnostic files from industrial PCs (IPCs) or servers.
- Future-Proofing New Equipment: If you are designing new machinery, choosing X-code provides a clear upgrade path as data requirements increase.
How to Avoid Costly Mistakes: Check Your Equipment First
The easiest way to guarantee you order the correct cable is to inspect the female connector port on your device (switch, camera, PLC, or I/O block).

- A D-code port will have four socket contacts and a single, flat keying notch.
- An X-code port will have eight socket contacts and a distinct "X" shaped keyway.
If you cannot physically inspect the port, check the device's datasheet or user manual. The specifications will clearly state "M12 D-Coded" or "M12 X-Coded" for its Ethernet ports.
Getting the Right Cable Assembly Quoted
Once you've identified the correct coding, you need to specify the complete assembly. To get an accurate quote, be sure to include the following details in your RFQ:
- Connector Coding: M12 D-code or X-code.
- Connector A: Male or female, straight or right-angle.
- Connector B: The connector on the other end (e.g., another M12, an RJ45, or unterminated/stripped wires).
- Cable Length: In meters or feet.
- Jacket Material: PVC for general use or PUR for applications requiring high flexibility, drag-chain use, or oil resistance.
- Shielding: Shielded cable is standard for industrial Ethernet to protect against electromagnetic interference (EMI).
- Quantity: For prototype, repair, or production volumes.
Frequently Asked Questions (FAQ)
1. Can I plug an X-code cable into a D-code device? No. The physical keying is different, and the connectors will not mate. This is an intentional design to prevent incorrect connections.
2. Is X-code always better because it's faster? Not necessarily. The cable must match the device port. Using an X-code cable with a device designed for 100 Mbps D-code offers no advantage and is not possible due to the physical incompatibility. Always choose the code that matches your hardware.
3. What about M12 A-code, B-code, or S-code connectors? Those are for different applications. A-code is typically for sensors and actuators (DC power and signal), B-code is for Fieldbus (like Profibus), and S/T/K/L-codes are for AC/DC power. They are not used for Ethernet communication.
4. Do I need shielded cable for industrial Ethernet? In almost all cases, yes. Factory floors are noisy electrical environments. Shielded cable (often specified as SF/UTP - Shielded/Foiled with Unshielded Twisted Pairs) is essential for protecting data signals from EMI generated by motors, VFDs, and other equipment.
Need Help Confirming the Right Cable?
Choosing the wrong connector can stop a project in its tracks. If you're not sure which coding matches your device, we can help.
Send us your switch model number, a photo of the device port, or the relevant datasheet. Our team can confirm the right cable for your application—free of charge.
Ready to order or need a quote? Send us your requirements through our contact form, and we'll provide a clear, detailed quotation for your M12 industrial Ethernet cable assemblies.
<!--[googlesitekit-end-of-content]-->