Abstract:As a key reform and innovation measure of national governance modernization, the digital transformation of megacity governance is essentially to build a digital city, that is, to reconstruct the urban operation logic and governance paradigm through digital technology to promote the high-quality development of megacities. From the perspective of public law, the institutional guarantee of digital governance in megacities should take people’s cities for the people as its value orientation, take the constitution as its order foundation, and achieve the balance between governance efficiency and rights protection through the dual adjustment of legal norms and organizational structure. At present, the digital transformation of megacity governance and the construction of the rule of law in China need to be further integrated. First, reform and innovation have put forward higher requirements for the legal norm system. There are signs of inappropriate convergence between legal norms and between legal norms and practical applications. For example, new legal relationships such as public data sharing and algorithmic decision-making involved in digital governance still lack high-level legislative support. Second, the comprehensive protection of civil rights has become a key issue to adapt to technological innovation and build a harmonious society. While improving administrative efficiency, digital governance tools may aggravate the risk of digital Leviathan due to the absence of rights protection mechanism. Third, the legal safeguards for the digital risk prevention linkage mechanism is insufficient. Urban operation is highly dependent on digital infrastructure, but the cross-domain linkage prevention and control mechanism of risks such as network security, data leakage and algorithmic malfunctions is not yet perfect. The overlapping of departmental responsibilities and data barriers will lead to the break of the supervision chain and insufficient coverage. The core of solving the above dilemma is to build a system of vertical convergence and horizontal coordination within the legal framework. First, under the control of the Constitution, promote the convergence of local legislation and various legal norms, and establish an elastic regulatory system of central legislation sets the framework and local legislation creates detailed rules. Second, clarify the functional orientation and power-responsibility boundary of digital governance institutions, integrate decentralized digital governance functions, solve the stubborn disease of data island and multi-head management, and form the two wings of the reform of the organization law of megacity governance together with legal procedures to prevent technical power from deviating from the rule of law. Third, improve the full-cycle prevention and control mechanism of digital risks, build an intelligent system based on the urban brain, and embed the early warning data into the legal procedure of emergency management synchronously, so as to realize the deep integration of technical rationality and legal rationality and comprehensively improve the emergency prevention and control ability of urban disasters. Only by implanting the spirit of the rule of law into the underlying logic of technical governance and injecting the concept of humanism into the system design can the rule of law guarantee of digital governance in megacities be realized, and the ultimate goal of digital governance in megacities in the future needs to return to science and technology for good, can we protect human dignity and urban civilization in the digital wave.