Background: During the outbreak of COVID-19, online public opinion related to the epidemic was rapidly generated and developed rapidly. If some online public opinions cannot be effectively responded to and guided, it will bring risks to social order. The government should understand how to use information on social media to grasp public demands, provide useful information in a timely manner and take countermeasures. Studying the formation mechanism of online public opinion during the outbreak can help the government make scientific decisions and improve risk management capabilities. Methods: The research selects the public opinion information of online platforms represented by WeChat, online communities, Sina Weibo and search engines, involving 75 relevant texts (1 January to 31 March 2022). According to the grounded theory method, using the QSR NVivo12 qualitative research software, the collected network texts were successively researched using open coding, axial coding and theoretical coding. Results: The structure of online public opinion during the COVID-19 epidemic was obtained. The operation mechanism of the online public opinion system about COVID-19 was mainly affected by the interaction of online public opinion objects, online public opinion subjects, online public opinion intermediaries and government forces. It was based on social facts and citizens’ appeals as the starting point, subject behaviors and prevention and control measures as the focus, government’s governance as macro-control and citizens’ evaluation as the guide. Conclusions: Scientific analysis of online public opinion is an important tool to identify and manage risks and improve the quality of government activities. Online public opinion has the function of assisting government decision-making, and the government can identify the important information reflected in it, especially the mainstream public opinion, as a reference for decision-making. By taking effective measures and properly responding to citizens’ reasonable demands, the government can prevent social risks and avoid new negative public opinions. Contributions: According to the characteristics of the basic model of online public opinion, this study provides risk mitigation suggestions for Chinese public sectors to use online public opinion, optimize epidemic prevention policies and formulate strategic measures.