Measurements are presented of the B$^0_\mathrm{S}$$\to$$\mu^+\mu^-$ branching fraction and effective lifetime, as well as results of a search for the B$^0$$\to$$\mu^+\mu^-$ decay in proton-proton collisions at $\sqrt{s}$ = 13 TeV at the LHC. The analysis is based on data collected with the CMS detector in 2016-2018 corresponding to an integrated luminosity of 140 fb$^{-1}$. The branching fraction of the B$^0_\mathrm{S}$$\to$$\mu^+\mu^-$ decay and the effective B$^0_\mathrm{S}$ meson lifetime are the most precise single measurements to date. No evidence for the B$^0$$\to$$\mu^+\mu^-$ decay has been found. All results are found to be consistent with the standard model predictions and previous measurements.