Due to the growing demand for energy and imminent environmental issues, hydrogen energy has attracted widespread attention as an alternative to traditional fossil energy. Platinum (Pt) catalytic hydrogen evolution reaction (HER) is a promising technology to produce hydrogen because the consumed electricity can be generated from renewable energy. To overcome the high cost of Pt, one effective strategy is decreasing the Pt nanoparticle (NP) size from submicron to nano-scale or even down to single atom level for efficient interacting water molecules. Herein, atomically dispersed Pt and ultra-fine Pt NPs embedded porous carbons were prepared through the pyrolysis of Pt porphyrin-based conjugated microporous polymer. As-prepared electrocatalyst exhibit high HER activity with overpotential of down to 31 mV at 10 mA cm−2, and mass activity of up to 1.3 A mgPt−1 at overpotential of 100 mV, which is double of commercial Pt/C (0.66 A mgPt−1). Such promising performance can be ascribed to the synergistic effect of the atomically dispersed Pt and ultra-fine Pt NPs. This work provides a new strategy to prepare porous carbons with both atomically dispersed metal active sites and corresponding metal NPs for various electrocatalysis, such as oxygen reduction reaction, carbon dioxide reduction, etc.