Abstract In reality, consumers often perceive safety risks from some peer‐to‐peer sharing services such as ride‐sharing and home‐sharing, which would hinder them from participating in service sharing. To deal with the safety risks, some sharing platforms and governments have taken the risk prevention measures. This paper studies the optimal pricing and the safety investment for a sharing platform. In this study, three scenarios are investigated, namely, (1) no risk prevention measures, (2) only the platform takes the risk prevention measures, and (3) both the platform and the government take the risk prevention measures. We find that when both the platform and the government take the risk prevention measures, the benefits of the platform, consumers, and service providers, as well as social welfare, will decrease under certain conditions. Additionally, under a certain condition, taking the risk prevention measures can achieve a Pareto improvement for the platform, consumers, and service providers.