Raspberry Pi 40-Pin GPIO Header Pinout
40-pin header, every model since the Pi B+ (2014), including Pi 4 and Pi 5. Check your board against its silkscreen before wiring power.
What changed between the models
The header is the one part that barely moved: pins 1 to 26 have meant the same thing since the 2012 Model B rev 2, and the B+ added pins 27 to 40 on top without disturbing them. Everything else on the board was rearranged more than once.
| Model | Year | Header | USB | Ethernet | Video | Power | Storage | Wireless |
|---|---|---|---|---|---|---|---|---|
| 1 Model B | 2012 | 26-pin | 2 | 10/100 | HDMI + composite | micro USB | SD card | none |
| 1 Model B+ | 2014 | 40-pin | 4 | 10/100 | HDMI + AV jack | micro USB | microSD | none |
| 2 Model B | 2015 | 40-pin | 4 | 10/100 | HDMI + AV jack | micro USB | microSD | none |
| 3 Model B | 2016 | 40-pin | 4 | 10/100 | HDMI + AV jack | micro USB | microSD | Wi-Fi n, BT 4.1 |
| 3 Model B+ | 2018 | 40-pin | 4 | gigabit, capped near 300 Mbps | HDMI + AV jack | micro USB | microSD | Wi-Fi ac, BT 4.2 |
| 4 Model B | 2019 | 40-pin | 2 x 3.0 + 2 x 2.0 | true gigabit | 2 x micro HDMI + AV jack | USB-C | microSD | Wi-Fi ac, BT 5.0 |
| 5 | 2023 | 40-pin | 2 x 3.0 + 2 x 2.0 | true gigabit | 2 x micro HDMI, no AV jack | USB-C, 5 V 5 A | microSD | Wi-Fi ac, BT 5.0 |
Three of those differences bite in practice. The Model B's 26-pin header stops at pin 26, so any HAT or diagram that references pin 32 or pin 40 assumes a B+ or later. The Pi 4 is the odd one out for port placement: it swapped the Ethernet and USB sockets to the opposite ends, and the Pi 5 put them back, which is why a case cut for a Pi 4 fits nothing else. And the Pi 5 dropped the analogue AV jack entirely, so composite video and headphone output now need a USB or HDMI device.
The Pi 5 also added parts nothing before it had: a PCIe FFC connector for NVMe, a real power button, an RTC battery header and a dedicated fan connector.
Physical pins versus GPIO numbers
The small numbers inside the header are physical positions: pin 1 top left, pin 2 top right, odd down the left, even down the right. The labels are BCM GPIO numbers, which is what your code uses. When a tutorial says "pin 18", find out which scheme it means before wiring.
3.3 volts, no negotiation
GPIOs are 3.3 V with no protection worth trusting. The 5V pins come straight off the supply: handy for powering accessories, destructive anywhere near an input.
Reserved pins
ID_SD and ID_SC (physical 27 and 28, GPIO0 and GPIO1) are the HAT identification EEPROM bus. Leave them free unless you are building a HAT.
Sources and datasheets
This diagram was cross-checked against the manufacturer documentation below plus at least two independent references before publishing. When they disagreed, the manufacturer won.
More boards and plugs live on the pinouts index.