How to connect a Inductive Proximity Sensor Switch NPN DC6-36V to PIC18F4550 5V
You can use an optocoupler as follows:







simulate this circuit &ndash; Schematic created using CircuitLab

Choose an optoisolator that has more that sufficient CTR such as a TLP291-4(GB,E). 

You can get such optoisolators 4 to a package, so only two would be required. The 12V supply that powers the proximity detectors does not need to share a ground (and probably should not share a ground) with the microcontroller. 

Edit: If you want a through-hole package, one suitable type is the TLP624-4(F)