8,642 Spanish Laws in Git: What Legislation-as-Code Looks Like

4 min read 2 sources explainer
├── "Legislation already behaves like code — Git makes the implicit versioning explicit"
│  ├── enriquelop (Hacker News) → read

López built legalize-es on the premise that every legislative reform is fundamentally a diff against existing law. By storing 8,642 Spanish laws as Markdown files with reforms as commits, he makes the entire change history navigable through standard Git tooling like log, diff, and blame — tools developers already know.

│  └── legalize-dev (GitHub) → read

The organization's repo description and structure frame legislation as a natural fit for version control. The choice of Markdown over PDF or XML signals a belief that laws should be stored as diffable plain text, not opaque documents. The org name suggests plans to extend this approach beyond Spain.

├── "The real problem is that legal publishing systems treat law as documents, not data"
│  └── top10.dev editorial (top10.dev) → read below

The editorial argues that official systems like Spain's BOE, France's Légifrance, and the U.S. Government Publishing Office bury change history in human-language amendment text like 'Article 23.2 is hereby modified to read as follows' — essentially human-language patches no machine can reliably parse. The value of legalize-es isn't that laws belong in Git, but that it exposes how current formats actively hide the versioned, dependency-graph nature of legislation.

└── "Git's entire toolchain — blame, bisect, cherry-pick — becomes immediately applicable to statutory text"
  └── top10.dev editorial (top10.dev) → read below

The editorial highlights that once law is in Git, the full ecosystem of developer tools applies without modification. Git blame can trace who introduced a specific clause, git bisect can find when a provision changed, and git diff shows exactly which paragraphs a reform altered — turning abstract legislative history into concrete, reviewable changesets.

What happened

A developer named Enrique López published legalize-es, a GitHub repository containing all 8,642 active Spanish laws as individual Markdown files. The key design choice: every legislative reform is stored as a Git commit. The entire history of Spanish statutory changes becomes navigable through standard Git tooling — `git log`, `git diff`, `git blame`, `git bisect`.

The repo hit 736 points on Hacker News and accumulated over 400 GitHub stars within days. The project lives under the `legalize-dev` organization, suggesting plans beyond a single country's legal corpus.

The core insight isn't that laws belong in Git — it's that legislation already behaves like code, and we've been storing it in formats that hide that fact.

Why this is a developer story, not a legal one

Laws are versioned documents with dependencies. A tax reform amends three articles of the income tax law, cross-references two EU directives, and supersedes a 2014 royal decree. That's a dependency graph. Every practicing developer has dealt with worse.

The problem is that legal publishing systems — Spain's BOE, France's Légifrance, the U.S. Government Publishing Office — treat law as documents, not data. You get PDFs, sometimes HTML, occasionally XML. But the change history is buried in amendment text like "Article 23.2 is hereby modified to read as follows..." — a human-language patch that no machine can reliably parse.

legalize-es solves this by making the diff first-class. Want to know what Spain's data protection law looked like before the 2023 reform? `git log --oneline ley-organica-3-2018.md`. Want to see exactly which paragraphs changed? `git diff abc123..def456`. Every tool in the Git ecosystem — blame, bisect, log, cherry-pick — suddenly applies to statutory text.

This isn't the first attempt. The United States Congress has been publishing bill text in XML (USLM format) since 2013, and the `@unitedstates` project on GitHub has scraped legislative data for over a decade. France's Légifrance publishes consolidated texts via an API. Germany's OffeneGesetze project exposes the Federal Law Gazette. Estonia stores its entire legal code in a structured database.

But legalize-es does something these projects mostly don't: it uses Git's native semantics rather than building custom infrastructure. The version control system itself becomes the legal change tracker. No custom API, no database schema, no web app required. Clone the repo, and you have the full legislative history offline.

The technical architecture

The repo structure is deliberately simple. Each law is a Markdown file named after its official identifier. The file contains the consolidated text — the current version of the law with all reforms applied. The Git history records when each reform was integrated.

This design has tradeoffs worth naming.

What works well: Markdown is human-readable, widely supported, and diffs cleanly. Git handles large repos (8,600+ files is well within limits — the Linux kernel has 80,000+). Standard tooling works out of the box. GitHub's web UI provides free hosting, search, and a diff viewer. CI/CD pipelines could validate cross-references or flag broken internal links.

What's harder: Legal text has semantic structure that Markdown only partially captures. Article numbers, paragraph references, cross-law citations, temporal applicability clauses — these have meaning that flat text doesn't encode. A `git diff` tells you which characters changed; it doesn't tell you whether that change affects your compliance obligations.

There's also the question of authority. The official text of Spanish law is published in the Boletín Oficial del Estado. legalize-es is a derivative work — accurate, but not authoritative. Any system built on top needs to account for that gap.

What practitioners should actually care about

If you work on compliance, regulatory technology, or govtech, this project is a useful signal about where infrastructure is heading.

Compliance-as-code pipelines. Companies subject to regulation (which is all of them) currently pay lawyers to read legislative changes and translate them into policy updates. If the legislative change is already a structured diff, the translation layer from "law changed" to "update internal policy" becomes partially automatable. Feed the diff to an LLM with your compliance framework as context, and you get a first-pass impact assessment in seconds instead of weeks.

Regulatory API design. If you're building APIs that expose regulatory data — tax rates, reporting requirements, licensing rules — a Git-backed source of truth simplifies your pipeline. Webhook on new commits, parse the diff, update your API. The repo becomes a free, versioned, machine-readable data source.

Legal search and retrieval. The combination of structured legal text and Git history creates a dataset that's immediately useful for retrieval-augmented generation (RAG) systems. You can embed not just the current text but the change history, enabling queries like "how has data retention policy evolved since 2018?"

Multi-jurisdiction expansion. The `legalize-dev` GitHub org name hints at this. If the pattern replicates across jurisdictions — Spain, France, Germany, EU directives — the result is a cross-border legal corpus in a uniform, developer-friendly format. That's the kind of infrastructure layer that entire companies get built on.

The broader pattern: documents becoming data

legalize-es fits a pattern that's been accelerating for a decade. Infrastructure-as-code replaced sysadmins editing config files. Policy-as-code replaced security teams writing Word documents. Design tokens replaced designers handing off Sketch files.

Legislation-as-code is the same move applied to a domain where the stakes are higher and the incumbents are slower. Governments will eventually adopt this — some already have. The question is whether they'll build proprietary systems or converge on open formats.

The developer who stores 8,642 laws in Git isn't just making a point about version control. They're building the infrastructure layer that legal-tech companies will depend on in five years.

For now, the practical move is simple: if you're in the regulatory or legal-tech space, clone the repo. Explore what's possible when law is data. If you're not, watch the `legalize-dev` org — when they add your jurisdiction, the compliance tooling opportunities get very real, very fast.

GitHub 874 pts 42 comments

legalize-dev/legalize-es: Spanish legislation as a Git repo — every law is a Markdown file, every reform a commit. 8,600+ laws.

Spanish legislation as a Git repo — every law is a Markdown file, every reform a commit. 8,600+ laws.

→ read on GitHub
Hacker News 774 pts 225 comments

I put all 8,642 Spanish laws in Git – every reform is a commit

→ read on Hacker News

// share this

// get daily digest

Top 10 dev stories every morning at 8am UTC. AI-curated. Retro terminal HTML email.