Whenever law is implemented in a digital system, the legal logic contained in authoritative legal texts must be translated into a form that machines can process. Today, this translation usually takes place separately within each system, and is performed repeatedly across public authorities, service providers, and technology vendors. This creates duplication, inconsistent implementation, limited interoperability and transparency, and dependencies on individual systems and providers. As AI becomes capable of performing state functions, this is no longer merely a question of technical efficiency. It concerns whether governments retain control over the legal logic that governs digital state action, and whether that action remains transparent, accountable, and subject to the rule of law.
The OECD’s 2020 publication Cracking the Code: Rulemaking for Humans and Machines marked an important step in exploring the potential of Rules as Code. Since then, initiatives in Australia, Canada, France, Germany, Japan, the Netherlands and New Zealand have explored different approaches to machine-readable and machine-executable rules. This consultation builds on that work by examining Law as Code more specifically as public digital infrastructure.
What is Law as Code?
For the purposes of this consultation, Law as Code refines the broader practice of Rules as Code in order to increase precision and clarity. It refers to the state-authorised provision of authoritative law in force, transformed into machine-executable representations and made available as shared public digital infrastructure. It goes beyond merely machine-readable formats: it implies the translation of law into encoded logic that a system can execute, an approach also known as computational law. These representations remain explicitly linked to the legal texts from which they derive.
They encompass the elements required for digital execution, such as conditions, exceptions, references, hierarchies, responsibilities, time limits, discretionary powers, and legal consequences. Together they provide a common reference structure that can be used across public authorities, courts, digital applications, and AI systems.
The authoritative legal text remains the legally binding source. Law as Code neither changes the law nor affects its interpretation or the institutional responsibilities governing it, and it does not decide individual cases. Interpretive, discretionary, and evaluative elements remain visible as such, rather than being silently converted into deterministic rules.
Why Law as Code, and why now?
As societies become increasingly digital, democracies need to ensure that law can be applied in digital environments in ways that remain transparent, traceable, accountable, and under public control. This concerns the ability of states to uphold the rule of law and to preserve their sovereignty as more public functions become digitally mediated.
Law as Code offers an infrastructure approach to this challenge. By making machine-executable legal logic available as a shared, publicly authorised resource, it could reduce duplicated implementation effort, enable interoperability, strengthen trust through transparency and reviewability, and provide a stable and verifiable basis on which AI systems can operate within the law.
AI makes the exploration of this approach particularly timely. As AI systems become able to perform tasks associated with state action, it becomes more urgent to determine how legal constraints, accountability, and institutional responsibilities are preserved. At the same time, AI may make it possible to transform and maintain legal logic at a scale that was previously difficult to achieve. Law as Code therefore warrants examination not only as a means of improving efficiency, but as a potential foundation for a capable, sovereign, and democratic digital state.
In practice, Law as Code provides the shared machine-executable legal logic on which governments can deliver public services and businesses can automate regulatory compliance. It thereby eliminates the translation gap between legal text and practical application, creates clarity and consistency, and could unlock significant gains in efficiency and trust across government, business, and society as a whole.