Skip to content
RAG Repo

Legislation.gov.uk

Legislation.gov.uk is the official home of the UK statute book, managed by The National Archives. It publishes primary legislation (Acts of the UK Parliament and the devolved legislatures in Scotland, Wales, and Northern Ireland) alongside secondary legislation (statutory instruments), stretching from medieval statutes still in force through to laws passed this year. Crucially, many items exist in more than one version: the law as originally enacted, and the current consolidated text with later amendments folded in.

Everything is available as structured XML built on the Crown Legislation Markup Language, and as linked data, where every Act, section, and subsection has its own stable web address. Add "/data.xml" to almost any page URL and you get the machine-readable version of that provision back. A documented interface lets you pull content in bulk, so you can load whole Acts, or just the sections you need, rather than scraping HTML pages one at a time.

This structure is a gift for RAG. Because each provision is individually addressable, you can chunk at the section level and cite the exact clause a model relied on, rather than pointing at a whole document. The point-in-time feature lets you retrieve the law as it stood on a given date, which matters when you are reasoning about events that happened under an earlier version of a statute.

Two caveats. Coverage of the fully up-to-date consolidated text is not complete: some amendments are still being applied, and pages flag outstanding changes, so do not assume the "current" version is always fully revised. Revised text is also mostly limited to legislation from 1991 onward. On licence, the content sits under the Open Government Licence v3.0, which lets you copy, adapt, and reuse it commercially, provided you credit the source and link to the licence. For UK legal RAG this is the primary source; add a case law service such as the National Archives' Find Case Law for court judgments alongside it.

uklegislationstatuteslinked-datagovernment

Related sources