Legalize — Laws as Code
Service

Legalize — Laws as Code

2026.04.08
·Web·by 권준호
#Git#grep#Markdown#OpenAPI#YAML

Key Points

  • 1This project converts all South Korean legislation into Markdown files, treating each amendment as a Git commit, allowing users to easily track and compare changes.
  • 2Utilizing official data from the National Legislation Information Center, laws are structured with YAML metadata and versioned by public date, enabling search, history checks, and diff comparisons via standard Git commands.
  • 3By integrating legal texts into a Git repository, the system offers a transparent and accessible way to explore legislation and its evolution using familiar development tools, eliminating the need for specialized viewers or subscriptions.

This paper introduces a novel system for managing and interacting with Korean legal statutes (laws, presidential decrees, and ministerial ordinances) by transforming them into version-controlled Markdown files within a Git repository. The core methodology leverages standard software development tools to enhance the accessibility, searchability, and traceability of legal information.

The system's operational flow is as follows:

  1. Data Acquisition: Official legal data is sourced directly from the National Law Information Center's OpenAPI (국가법령정보센터 OpenAPI). This ensures that the dataset is always based on authentic, official legal texts, avoiding reliance on summaries or static PDF documents.
  1. Data Structuring and Normalization:
    • Each legal statute is converted into a Markdown file. While not explicitly detailed, the mention of "YAML 메타데이터" suggests that each file includes a YAML front matter containing structured metadata relevant to the specific law, such as its official name, type (law, presidential decree, etc.), and promulgation dates.
    • The legal content within the Markdown files is structured to represent articles and clauses. For instance, an article (e.g., Article 809) is rendered with a distinct heading (e.g., ##### 제809조), and its sub-provisions are formatted accordingly (e.g., **①**).
    • Files are organized hierarchically in a kr directory. Related statutes (a law, its enforcement decree, and enforcement rules) are grouped into a single directory named after the law (e.g., kr/{법률명}/법률.md, kr/{법률명}/시행령.md, kr/{법률명}/시행규칙.md). Independent presidential decrees reside in their own dedicated directories (e.g., kr/{대통령령명}/대통령령.md).
  1. Version Control via Git:
    • Every amendment (개정) to a legal statute is recorded as a distinct Git commit.
    • Crucially, each commit is tagged with the actual promulgation date (공포일자) of the amendment, providing an accurate historical timestamp.
    • This Git-centric approach allows users to:
      • Track History: Utilize git log to view the complete revision history of any law or specific file.
      • Compare Versions: Employ git diff to precisely identify changes between any two versions of a law. The example vividly demonstrates this by showing the specific line additions (+) and deletions (-) for Civil Law Article 809, illustrating the shift from prohibiting "Dongseongdongbon" marriages to "incestuous marriages" in a 2005 amendment.
      • Search: Leverage standard command-line tools like grep to search for specific terms across the entire legal corpus or within particular laws (e.g., grep -n "혼인" kr/민법/법률.md). The -rl flag can be used for recursive searches across directories.

The overarching aim is to democratize access to legal information by providing a transparent, version-controlled, and easily searchable dataset that can be cloned and explored using universally familiar developer tools, eliminating the need for proprietary viewers or subscription services.