Abstract We report on the discovery of the companion star to the millisecond pulsar J1342+2822B in the globular cluster M3. We exploited a combination of near-ultraviolet and optical observations acquired with the Hubble Space Telescope in order to search for the optical counterparts to the known millisecond pulsars in this cluster. At a position in excellent agreement with that of the radio pulsar J1342+2822B (M3B), we have identified a blue and faint object (m F275W ≈ 22.45) that, in the color–magnitude diagram of the cluster, is located in the region of He core white dwarfs (WDs). From the comparison of the observed magnitudes with theoretical cooling tracks we have estimated the physical properties of the companion star: it has a mass of only 0.19 ± 0.02 M ⊙, a surface temperature of (12 ± 1) × 103 K, and a cooling age of 1.0 − 0.3 + 0.2 Gyr. Its progenitor was likely a ∼0.84 M ⊙ star, and the bulk of the mass-transfer activity occurred during the subgiant branch phase. The companion mass, combined with the pulsar mass function, implies that this system is observed almost edge-on and that the neutron star (NS) has a mass of 1.1 ± 0.3 M ⊙, in agreement with the typical values measured for recycled NSs in these compact binary systems. We have also identified a candidate counterpart to the wide and eccentric binary millisecond pulsar J1342+2822D. It is another WD with a He core and a mass of 0.22 ± 0.2 M ⊙, implying that the system is observed at a high inclination angle and hosts a typical NS with a mass of 1.3 ± 0.3 M ⊙. At the moment, the large uncertainty on the radio position of this millisecond pulsar prevents us from robustly concluding that the detected star is its optical counterpart.