Open Standardv0.2 Draft

LegalDownMarkdown for Legal Documents

An open standard for writing contracts and legal documents in plain text. Human-readable, machine-parseable, and built for collaboration. Write once — render to PDF, DOCX, or HTML. Track every change with Git.

OpenStandard
PlainText Format
AnyEditor Works
GitNative
Resolved at render time
{{money: 50000, currency=USD}}USD 50,000.00
As set forth in Section {{ref: payment-terms}}...As set forth in Section 2…
shall terminate on {{date: 2026-06-01}}shall terminate on June 1, 2026
within {{duration: 30, unit=D}}within 30 days
The Status Quo

The Problem with Legal Documents Today

Four problems that cost legal teams thousands of hours a year.

Trapped in Proprietary Formats

Contracts live inside Word files full of hidden formatting and binary noise. Sharing one means emailing attachments and hoping.

Numbering Breaks Constantly

Move one section and half the cross-references point somewhere else. Renumbering clauses by hand is work nobody should still be doing.

No Real Version Control

Track Changes turns a negotiation into an unreadable mess, and comparing two drafts means reading both. Nothing records who changed what.

Opaque to Automation

Binary and XML formats bury structure under formatting markup. No tool can reliably pull out a clause or a liability cap without guessing.

Try It

Edit the Contract, Watch It Render

A real document, checked by the reference validator on every keystroke. Edit the source and the contract follows.

Move a whole section and watch every number and cross-reference follow it.
Delete a definition and see the validator name the term that lost it.
Start from
service-agreement.lgdSource

Structure comes from Markdown headings; {#ids} make them referenceable. Parties, dates and governing law go in the YAML header at the top.

Rendered
Valid — no problems found

Service Agreement

Providers

Acme Corporation

a legal entity, id DE-12345678

123 Main Street, Dover, DE 19901

represented by John Smith, Chief Executive Officer

(the “Acme”)

and

Clients

Beta Industries Inc.

a legal entity, id TX-87654321

456 Oak Avenue, Austin, TX 78701

(the “Beta”)

Effective April 1, 2026 · Governed by the law of Delaware

This Agreement is entered into between Acme and Beta on April 1, 2026.

1Definitions

Deliverables means the reports and software described in the statement of work.

2Payment Terms

Acme shall deliver the Deliverables and Beta shall pay USD 50,000.00 within 30 days of acceptance.

2.1Late Payment

If payment under Section 2 is not received by May 15, 2026, interest accrues at 1.5% per month.

2.2Invoices

Each invoice must quote INV-2026-001 and the purchase order [_____].

Validator output

The reference validator reports nothing against this document.

Checked by legaldown-validator, the tool you put in CI. Real output is styled by a style template and exported to PDF or DOCX. This page renders up to 4,000 characters; the command-line tool has no limit.

The Format

What You Are Actually Writing

A LegalDown file is a YAML header followed by a Markdown body, plus a small set of constructs for what contracts need and Markdown lacks.

An open format, not a product — free to use and to implement
A superset of CommonMark: all standard Markdown is already valid LegalDown
Plain UTF-8 text with the .lgd extension, readable in any editor
Three conformance levels and an Assembly capability, so every tool states what it supports

Headings Are Structure

# is a top-level provision, ## a subsection, down to five levels. The headings are the structure.

Stable Identifiers

{#payment-terms} after a heading assigns a permanent id. References point at the id, never the number.

Tracked Defined Terms

Declare with {{def: id}}, use with {{term: id}}. Validation proves every referenced term is defined exactly once, and links it back.

Structured Metadata

Parties, dates, governing law and document type sit in the YAML header, where any tool can read them.

The document_type field adapts the structure and metadata rules:

1

Contracts

Agreements between named sides — NDAs, MSAs, employment, licence, lease.

2

Unilateral acts

Issued by one party — notices, declarations, powers of attorney.

3

Collective acts

Adopted by an organisation — bylaws, internal regulations, board resolutions.

Templates Carry Their Own Logic

One file holds every variant. Answer its questions and assembly writes an ordinary document, the same bytes every time — and a valid template assembles cleanly for every valid set of answers.

questions:

Declared in the header, with prompts and defaults.

{#id when=vat}

Keeps or drops a whole section, item or paragraph.

{{choose: ...}}

Swaps a phrase; every answer must be covered.

> [!DRAFTING]

Guidance for the drafter, removed on assembly.

Syntax

The LegalDown Directive Toolkit

Inline directives, written as {{directive: value}}, mark up the legal-specific parts. Open one to see what it renders to.

"Term" {{def: id}}Define a Term

The term in quotation marks, then {{def: id}}. The quotes are never rendered; an omitted id is derived from the term.

"Confidential Information" {{def: confidential-info}} means...
Confidential Information means…
{{term: term-id}}Use a Defined Term

Uses a defined term anywhere, linked back to its definition.

The {{term: confidential-info}} shall be...
The Confidential Information shall be…
{{ref: section-id}}Cross-Reference a Section

Resolves to the section's current number, linked. You write 'Section' yourself, so the format works in any language.

As set forth in Section {{ref: payment-terms}}...
As set forth in Section 2…
{{party: name}}Reference a Party

A party declared in the frontmatter, with an optional label= for inflection.

{{party: acme}} shall deliver...
Acme shall deliver…
{{side: name}}Reference a Side

The collective counterpart of {{party:}} — a whole side at once, for obligations that bind a group jointly.

The {{side: clients}} shall be jointly liable...
The Clients shall be jointly liable…
{{date: YYYY-MM-DD}}Calendar Date

An unambiguous ISO 8601 date, formatted for the reader's locale.

shall terminate on {{date: 2026-06-01}}
shall terminate on June 1, 2026
{{money: amount, currency=X}}Monetary Amount

An amount with an ISO 4217 currency code, formatted locally and never rounded.

{{money: 50000, currency=USD}}
USD 50,000.00
{{duration: value, unit=U}}Time Duration

A time span with an explicit unit: S, MIN, H, D, W, MO or Y.

within {{duration: 30, unit=D}}
within 30 days
{{field: value, type=t}}Custom Typed Value

A value of your own type — case numbers, invoice numbers — declared in frontmatter to validate it.

{{field: INV-2026-0042, type=invoice-id}}
INV-2026-0042
{{placeholder: id}}Fillable Placeholder

A blank to fill in — text, date, money or duration. A template's question gives it a prompt.

{{placeholder: fee, type=money, currency=EUR}}
a ruled blank, typed as money in EUR
{{choose: question, a=text, b=text}}Inline Choice

In a template, a phrase picked by an answer. Every answer must be listed, so a new option cannot drop text.

interim relief from {{choose: forum, courts="a court", arbitration="an arbitrator"}}
interim relief from [a court / an arbitrator]
{{attach: id}}Reference an Attachment

A schedule, exhibit or annex declared in the frontmatter, by its title.

as specified in {{attach: schedule-a}}
as specified in Schedule A
{{include: path}}Include a Fragment

Splices in a fragment file: shared definitions, standard clauses.

{{include: fragments/standard-terms.lgd}}
the fragment's own text, spliced in here
Reference Implementation

The Reference Validator

A standard is only as good as the tool that enforces it. legaldown-validator parses, validates and serialises LegalDown documents — and it is what checks the playground above.

legaldown-validatorTERMINAL
$ pip install legaldown-validator
$ legaldown validate contract.lgd

Exit code 1 on any error-level diagnostic — or on any diagnostic at all under --strict — so a broken contract never reaches signature.

What It Checks

Seventy-nine of the specification's 116 rules, each at the severity the specification assigns it.

StructureHeading depth, skipped levels, hardcoded section numbers
Cross-referencesTargets that do not exist or point at an attachment
AnchorsDuplicate, malformed, colliding, or misplaced identifiers
DefinitionsUndefined terms, duplicate ids, ambiguous or missing quoted span
Parties & sidesUnknown or malformed names, invalid types, minimum counts
ValuesInvalid dates, money without currency, bad durations and field types
PlaceholdersInvalid or inconsistent types, currencies and units
TemplatesQuestions, conditions, choices, references a condition can remove
AttachmentsUndeclared, duplicate, empty, or unreferenced attachments
AmendmentsTerms the original never defines, definition overrides
MetadataDocument type, dates, sides, declared version

Every Finding Has a Rule Id

Each diagnostic carries the specification's stable rule id beside its severity. Suppress one check, escalate another, or gate a build on exactly the rules you care about.

Command Line and Python API

Validate a file or a whole tree from the shell, or call parse_document, validate_document and serialize_document directly — the same engine either way.

Built for CI Pipelines

JSON output for annotations and dashboards, --strict to tighten the gate, --ignore to grant one exception, and --final to refuse a document with anything left to fill in.

Validate on Every Commit

Two lines in a workflow file put every contract in the repository under continuous validation. The exit code fails the job; rule ids let you grant exceptions without switching whole checks off.

View legaldown-validator on GitHub

Python 3.11+ · MIT licensed · one dependency (PyYAML) · Level 1 — Core conformance, verified against the specification's fixtures

.github/workflows/contracts.yml
- run: pip install legaldown-validator
- run: legaldown validate contracts/ --warnings-as-errors
Comparison

LegalDown vs. Traditional Drafting

Eight things that change when a contract is plain text with explicit structure.

Feature Traditional LegalDown
Section numbering
Manual — breaks when you move sections
Automatic — always correct at render time
Cross-references
Hardcoded text — breaks silently
Identifier-based — validated automatically
Version comparison
Track Changes — unreliable and hard to read
Git diff — clear, line-by-line comparison
Defined terms
Manual bold formatting — no link to definition
Declared & linked — validated for consistency
Formatting & style
Embedded in document — inconsistent across versions
Separate style templates — always consistent output
Templates
A copy per variant — the logic lives in the drafter's head
Questions and conditions in the file — assembled deterministically
AI analysis
Requires parsing binary or XML formats
Native plain text — directly processable by any LLM
Collaboration
Email attachments — version confusion inevitable
Git branches — full audit trail, merge support
AI & Automation

Built for AI & Automation

Traditional legal documents need expensive parsing and heuristic extraction. A LegalDown document is already structured data.

Feed Directly to LLMs

Pass a whole contract to any language model with no preprocessing — it sees structure, not formatting noise.

Structured Data Extraction

Parties, dates and governing law are declared in YAML. Parse the header and you have the data.

Clause Comparison at Scale

One set of structural rules, so liability caps or payment terms compare across a whole portfolio.

Get Started

LegalDown is an open standard. Read the specification, try the validator, and open an issue if the format does not fit the way you work.

1

Write

Draft in any text editor — Markdown for structure, directives for the legal parts.

2

Validate

Run legaldown validate. Broken references and undefined terms surface before anyone signs.

3

Render

Generate PDF, DOCX or HTML from a style template; numbering and references are computed.

4

Collaborate

Commit to Git: real diffs, real history, clean merges.