WADA-DEV(7) $ /en/blog/houritsu-japanese-laws-as-git/

NAME

houritsu-japanese-laws-as-git — I Turned Every Japanese Law into Git History

SYNOPSIS

I know nothing about law, but AI has made research so fast that I wanted to see how far I could get. So I turned every Japanese law into a git repository with one commit per amending law. git log shows how a law was amended and git diff shows what changed.

DESCRIPTION

Why I Built It

It was just a whim.

I know nothing about law. But AI has made research in unfamiliar fields very fast. While browsing the Diet’s minutes API, it struck me that laws in git might be fun. I wanted to see how far I could get in a field I don’t know, with AI alongside.

In Japan, a law is amended by another law, “an Act partially amending the X Act”. Its text is a list of edit instructions, like “in Article 3, replace ‘A’ with ‘B’”. Reading it, it is hard to see what actually changed.

That is a diff, I thought. Put each law’s text in a file and make each amendment one commit, and git diff should show exactly what changed.

Germany already has this: bundestag/gesetze keeps the federal laws in git. Japan has elaws-history, a daily snapshot of every law on e-Gov, but it stores the raw XML and does not read as a history of amendments. So I gave it a try.

What I Built

houritsu is a git repository of Japanese laws.

  • It holds every law on e-Gov: Acts, Cabinet Orders, Ministerial Ordinances and more. There are 8,982 law files now and 23,338 commits on main.
  • One commit is one amending law coming into force. The commit date is the enforcement date.
  • One law is one markdown file, with its metadata in frontmatter.
  • Amendments promulgated but not yet in force are on the upcoming branch.
  • Every morning it fetches what changed on e-Gov and adds the commits.

The data comes from the e-Gov law API v2. The converter, houritsu-builder, is written in Rust.

Using It

The History of a Law

git log on the Act on the Protection of Personal Information lists the amending laws that touched it.

$ git log --format='%ad %s' --date=short -- laws/act/415/415AC0000000057.md
2026-10-01 日本学術会議法 施行
2026-07-17 防災庁設置法の施行に伴う関係法律の整備等に関する法律 施行
2026-07-17 個人情報の保護に関する法律等の一部を改正する法律 施行
2026-06-24 民法等の一部を改正する法律の施行に伴う関係法律の整備等に関する法律 施行
2026-05-21 民事訴訟法等の一部を改正する法律 施行
...

Not only amendments aimed at this Act: laws about the Science Council of Japan and the new Disaster Management Agency rewrote it along the way.

What Changed

The 2026-10-01 commit for the Science Council of Japan Act added one row to a schedule of the personal information Act.

<tr>
<td>日本学術会議</td>
<td>日本学術会議法(令和七年法律第七十号)</td>
</tr>
<tr>
<td>日本銀行</td>

The Science Council became a corporation instead of a government body, so it joined the list of corporations the Act covers.

The 2026-07-17 amendment of the Act changed the review clause in the supplementary provisions of the 2020 amendment.

政府は、この法律の施行後三年ごとに、個人情報の保護に関する国際的動向、…
政府は、この法律の施行後三年を目途として、個人情報の保護に関する国際的動向、…

“Review every three years” became “review in about three years”. That is hard to dig out of the amending law, and obvious in a diff.

Which Amending Law, Which Bill

The commit message carries the amending law’s number, its promulgation date and the other laws it rewrote. For a law passed by the Diet, it also links the bill in the House of Representatives database.

日本学術会議法 施行
改正法令: 令和七年法律第七十号
公布日: 2025-06-18
施行日: 2026-10-01
変更された法令:
- 国家公務員法(昭和二十二年法律第百二十号)
- 日本学術会議法(昭和二十三年法律第百二十一号)(廃止)
...
Bill: 閣法 第217回国会 第36号
Bill-Url: https://www.shugiin.go.jp/internet/itdb_gian.nsf/html/gian/honbun/g21709036.htm

The message also shows one amending law rewriting a dozen or more laws at once.

Following One Article

git log -L follows a single article.

git log -L '/^##* *第十六条/,/^##* *第十七条/:laws/act/415/415AC0000000057.md'

Limits

  • History starts around 2015. e-Gov’s revision data fills in from then, so earlier amendments are missing.
  • git blame does not date the wording. Text that existed before 2015 all sits in the first commit.
  • The official text is the Official Gazette (官報). The statute text is unchanged, but this is not the official text and not legal advice.

Bonus: Git Cannot Commit Before 1970

I only learned this while building it: git cannot make a commit dated before 1970.

$ GIT_AUTHOR_DATE='1969-12-31T12:00:00+0000' GIT_COMMITTER_DATE='1969-12-31T12:00:00+0000' \
git commit --allow-empty -m test
fatal: invalid date format: 1969-12-31T12:00:00+0000

git stores a commit’s time as Unix time, seconds since 1970-01-01 00:00 UTC, and does not accept negative values. Even 1970-01-01 00:00 in Japan time is New Year’s Eve 1969 in UTC, so it is rejected too.

Japanese laws, though, go back to the Meiji era. The oldest commit in houritsu is the 1872-11-09 calendar reform decree (改暦ノ布告), which switched Japan to the solar calendar. There are 317 such pre-1970 commits.

So these commits are dated 1970-01-02, and the real enforcement date goes in the commit’s Enforced trailer and in the frontmatter.

Wrapping Up

Building it showed me that laws change far more often than I thought, and are often rewritten as a side effect of other laws. Even without knowing the law, once it is in the shape of data, you can browse it, and that was fun.

Next, I think it would be fun to combine houritsu with the Diet’s minutes API into something like a kokkai-cli: a tool that goes from a commit to the bill that made the amendment and the Diet debate on it. I’ll try it when I have time.

The data is CC BY 4.0 and the builder is MIT. If you try it and wish you could look at the laws some other way, let me know.

Source: e-Gov法令検索 (https://laws.e-gov.go.jp/), PDL1.0. Converted to markdown by houritsu-builder.

COMMENTS