Introducing a new way to review your PRs.

Read the announcement

freelawproject / courtlistener

A fully-searchable and accessible archive of court data including growing repositories of opinions, oral arguments, judges, judicial financial records, and federal filings.

View on GitHub

19 documents · Updated Nov 24, 2026

docs / case-law-data

Case law data

CourtListener builds a connected case-law corpus from court opinions and related court records. It joins each decision to a court, docket, source document, usable text, and legal relationships so the same data can support public reading, search, citation analysis, and later enrichment.

Corpus model

The corpus represents a decision as related records instead of one large document. A court places a case in a docket. An opinion cluster is the public case unit. One cluster can contain several opinions, such as a lead opinion, concurrence, or dissent. Each opinion keeps its own text, role, author, order, and source identity.

The main relationships move from case context to decision text and then to legal connections:

flowchart TD
    Court --> Docket
    Docket --> Cluster[Opinion cluster]
    Cluster --> Opinion
    Opinion --> Content[Opinion content]
    Cluster --> Citation[Reporter citations]
    Opinion --> OpinionCitation[Opinion citation]
    OpinionCitation --> Cluster
    RECAP[RECAP document] --> DocketEntry[Docket entry]
    DocketEntry --> Docket

This shape gives a decision one stable public destination while preserving the texts and sources that explain it. It also lets court-record data and case-law data share docket context without making every court filing an opinion.

References: cl/…/models.py• L292-382 cl/…/models.py• L2418-2529 cl/…/models.py• L3217-3472 cl/…/models.py• L3558-3717

Courts and dockets

A court provides the jurisdiction for a case. A docket joins that court to opinion clusters, filings, parties, attorneys, transfers, and appeal context. This boundary preserves court-record context even when the opinion comes from another source.

References: cl/…/models.py• L292-382 cl/…/tasks.py• L609-746 cl/…/views.py• L373-470

Opinion clusters

An opinion cluster is the public case unit for a decision. It holds shared case information such as the name, date, judges, procedural facts, precedential status, and reporter citations. The cluster also provides the stable home for its related opinions and source files.

References: cl/…/models.py• L2418-2684 cl/…/views.py• L1001-1060

Opinions and content

An opinion is one writing within a cluster. It records the writing's role, author, order, source document, and text. CourtListener keeps source forms such as HTML, XML, plain text, and OCR-derived text because they serve different needs and do not have equal quality.

The corpus selects the strongest usable text for display and citation finding while keeping the source evidence. This lets enrichment improve the reader view without losing the record of how the text entered the system.

References: cl/…/models.py• L3217-3279 cl/…/models.py• L3282-3472 cl/…/utils.py• L227-268 cl/…/utils.py• L862-889

Corpus acquisition

CourtListener acquires opinions from court sites, public case-law collections, direct court feeds, scanned collections, and suitable free RECAP documents. Each source supplies case facts and files to the shared docket, cluster, and opinion model.

The broad acquisition path turns source material into records and then into reader-ready data:

flowchart LR
    Sources[Court and public sources] --> Identify[Identify court and case]
    Identify --> Merge[Create or merge docket and cluster]
    Merge --> Files[Store source files]
    Files --> Extract[Extract usable text]
    Extract --> Enrich[Find legal relationships]
    Enrich --> Publish[Publish case and search views]

Source-specific jobs use the same goal even when their entry points differ. A direct state corpus supplies court facts and a PDF. A court probe discovers new dockets. A RECAP document can become an opinion when its text shows that it is case law. A Kessler batch can seed Illinois bankruptcy dockets, petitions, and final documents from PACER, then send the files through the normal document and text pipeline. A load ledger and durable watermarks make long imports restartable.

References: cl/…/import_tn.py• L27-151 cl/…/probe_scotus_dockets_daemon.py• L39-61 cl/…/kessler_ilnb.py• L35-124 cl/…/tasks.py• L3393-3518 cl/…/ledger.py• L54-113

Source reconciliation

Source records are evidence about one case or decision. Matching joins a new record to an existing one only when its identity is clear. Ambiguous matches fail instead of selecting a record at random. A partial source does not replace a trusted value with an empty one.

This rule protects the shared corpus as new sources add better names, dates, citations, text, or docket context. It also prevents a later source from creating a second public case for a decision already known to the system.

References: cl/…/utils.py• L391-566 cl/…/base.py• L389-498

Source files and extraction

Source files provide the evidence from which public text is made. The importer stores the file, extracts text, and keeps enough source information to compare versions and avoid duplicate documents. OCR remains an alternate path when a file has no usable text layer.

Structured extraction can also split one source document into several writings. The first writing remains the decision's main opinion. Additional writings become sibling opinions in the same cluster, while the source document remains attached once.

References: cl/…/centralia.py• L161-270 cl/…/centralia.py• L409-517 cl/…/extract_structured_opinions.py• L93-209 cl/…/import_tn.py• L113-150

RECAP opinion promotion

RECAP documents normally remain filings attached to docket entries. A suitable free document can become a trial-court opinion when its court, case type, source hash, extracted text, and case-law citations meet the opinion import rules.

The promotion flow is:

  1. Check the court and case type.
  2. Reject a document whose content hash already belongs to an opinion.
  3. Extract the document and check for case-law citations.
  4. Create the cluster and trial-court opinion with its docket origin.
  5. Queue case-name and citation enrichment.

The case-name step uses the extracted text to improve the cluster's names after creation. This lets the opinion enter the corpus with docket-derived names while later work supplies normalized names when the text supports them. The promotion keeps the docket origin and source history attached to the new opinion.

References: cl/…/tasks.py• L3393-3518 cl/…/tasks.py• L3534-3627 cl/…/utils.py• L166-201

Structured opinion extraction

Structured extraction turns a source PDF into cleaner opinion markup and separates the writings in a multi-writing decision. The system accepts the result only when it has enough text and usable markup to improve the current record. A rejected result leaves the existing opinion unchanged.

The extraction path is:

flowchart LR
    PDF[Stored opinion PDF] --> Doctor[Structured extraction service]
    Doctor --> Check[Quality checks]
    Check -->|Accept| Split[Store writings and shared sections]
    Check -->|Reject| Keep[Keep current opinion]
    Split --> Citations[Find citations and summaries]

This protects the corpus from a clean-looking but incomplete read. After an accepted split, citation finding runs for every saved writing so the new sibling opinions join the legal graph.

References: cl/…/centralia.py• L161-210 cl/…/centralia.py• L213-270 cl/…/centralia.py• L409-437 cl/…/extract_structured_opinions.py• L152-209

Public case data

The opinion cluster is the main public case destination. A case page brings together decision text, shared metadata, citations, downloads, docket context, and citation-based views. Search receives a published view so discovery can combine case fields with opinion text and relationships.

The public presentation details are in Opinion pages and publishing. The ingestion details are in Opinion ingestion. The legal-link details are in Citation analysis.

References: cl/…/views.py• L1001-1124 cl/…/views.py• L1198-1369 cl/…/documents.py• L1930-2266

Stable case access

Cluster identifiers and slugs provide the normal case path. When a cluster is replaced, a redirection record can send the old path to the current cluster. A sealed cluster returns a deliberate gone response instead of exposing the old case.

References: cl/…/models.py• L3520-3523 cl/…/decorators.py• L16-60

Search publication

Search records are a published view of the corpus. A cluster record supplies case names, court data, dates, judges, status, reporter citations, citation counts, and sibling opinion IDs. Child opinion records supply searchable text and opinion-specific fields.

This separation means a source change is not complete until its search view also reflects the new state. Citation links and parenthetical summaries use the same publication boundary.

References: cl/…/documents.py• L1930-2115 cl/…/documents.py• L2117-2289 cl/…/views.py• L1127-1195

Docket participants

Docket context includes the people and organizations connected to a case. The public parties view groups parties by role and can show termination dates, attorneys, firms, representation roles, and criminal charge data when those records exist. Large participant lists are paged so the same docket can remain usable as its records grow.

The docket page supplies a shared tab context for entries, parties, and other case data. The legacy and new parties views use the same prepared participant data, so a presentation change does not change the underlying case relationships.

References: cl/…/views.py• L482-562 cl/…/utils.py• L706-901 cl/…/docket_page.html• L188-277 cl/…/docket_parties.html• L20-173 cl/…/v2_docket_parties.html• L22-134

Citation graph

Case citations connect opinions into a legal graph. Citation work finds case references in opinion and RECAP text, resolves safe matches to known opinions, stores the relationship, and keeps uncertain references as durable work records.

This diagram shows how opinion text becomes a safe legal relationship or remains available for later work.

flowchart LR
    Text[Opinion or RECAP text] --> Detect[Find case references]
    Detect --> Resolve{One safe match?}
    Resolve -->|Yes| Link[Store citation relationship]
    Resolve -->|No| Unmatched[Store unresolved state]
    Link --> Counts[Update counts and search]
    Link --> Markup[Add reader-facing link]
    Unmatched --> Retry[Retry when corpus data changes]

Resolution uses reporter citation data first. Short and supra references use already resolved citations and case-name clues. A self-reference is excluded. A missing match and an ambiguous match remain separate because neither supports a safe case link.

Citation behavior is described in Citation analysis.

References: cl/…/match_citations.py• L45-69 cl/…/match_citations.py• L72-150 cl/…/match_citations.py• L153-234 cl/…/utils.py• L271-298

Citation relationships

Resolved citations create opinion-to-opinion relationships. The corpus derives cluster citation counts and search fields from these links. RECAP documents use a parallel relationship so filings can point to opinions without becoming opinions.

References: cl/…/models.py• L3664-3717 cl/…/utils.py• L271-298 cl/…/tasks.py• L3451-3512

Citation annotations

Resolved citations become links in published opinion text. A known citation links to the cited case and can include a pinpoint. An ambiguous citation goes to citation lookup. An unresolved citation is marked without inventing a case link.

The annotation keeps the source text shape when possible. It also handles plain text and large documents so citation markup does not change the meaning of the opinion.

References: cl/…/annotate_citations.py• L22-98 cl/…/annotate_citations.py• L101-160 cl/…/utils.py• L204-268

Unmatched citations

Unmatched citations preserve references that cannot yet support a safe link. Their state records whether the citation is absent from the known corpus, available but not yet applied, resolved, ambiguous, or failed. Later work can retry them when new opinions or citation data arrive.

References: cl/…/models.py• L13-68 cl/…/unmatched_citations_utils.py• L59-205

Enrichment lifecycle

Enrichment turns opinion text and source metadata into corpus links and reader features. It adds normalized people data, reporter citations, opinion relationships, citation counts, linked text, parenthetical summaries, case names, and searchable records.

When the system processes an opinion, it follows this sequence:

  1. Connect source metadata to the court, docket, cluster, and opinion.
  2. Select the strongest usable text while keeping source evidence.
  3. Find and resolve case citations against known records.
  4. Store resolved links and unresolved states.
  5. Save linked text and update citation counts.
  6. Group useful parentheticals and refresh public search data.

References: cl/…/centralia.py• L409-517 cl/…/tasks.py• L3393-3627 cl/…/utils.py• L227-298 cl/…/views.py• L1142-1327

Parenthetical summaries

Parentheticals are short descriptions attached to citations. The system groups similar descriptions so a case page can show repeated legal points once instead of displaying many near-duplicate statements. Groups favor descriptions that are both useful and common in the corpus.

The summaries are derived from citation text rather than treated as new legal authority. They support discovery and reading while the underlying citation and opinion records remain the source of truth.

References: cl/…/group_parentheticals.py• L67-140 cl/…/group_parentheticals.py• L202-288 cl/…/views.py• L1296-1336

Change checklist

When these files or sections are changed, remember to consider these:

  • Changes to cluster, opinion, citation, or content identity must remain aligned with public URLs, source hashes, search records, and cluster redirections.
  • Changes to preferred text or extraction quality must keep display text, citation finding, and search text on the same usable source.
  • Changes to source matching must preserve safe duplicate detection and must not erase trusted values when a source has no value.
  • Changes to structured extraction must keep writing order, opinion type, author links, shared headmatter, and citation reprocessing aligned.
  • Changes to RECAP promotion must keep docket origin, content-hash checks, trial-court type, case-name enrichment, and citation finding consistent.
  • Changes to PACER batch acquisition must keep case lookup, docket tags, document retrieval, PDF extraction, and downstream opinion promotion in the same chain.
  • Changes to court probes or import watermarks must preserve crash recovery and must not skip observed docket ranges.
  • Changes to citation resolution must keep no-match, ambiguous, self-reference, and resolved states distinct in stored records and public markup.
  • Changes to citation links, counts, or parenthetical groups must refresh related search fields and public case views.
  • Changes to participant preparation must keep party roles and firm associations scoped to the current docket and keep both parties-page designs on the same data shape.
  • Changes to PACER session renewal or request throttling must preserve complete bulk acquisition without exceeding court access limits.
  • Changes to a cluster replacement must preserve a replacement redirect or return a deliberate gone response.

Important failure modes

TriggerConsequenceGuard
A source match has several possible recordsThe importer can attach data to the wrong caseReject the ambiguous match
A partial source sends an empty valueTrusted case data is erasedKeep the existing value
A structured read is incomplete or has no usable markupThe public opinion becomes partial or blankCheck status, page quality, text coverage, and writing HTML before saving
A structured read finds several writings in an already split clusterDuplicate sibling opinions can be createdSplit only a cluster with one current opinion
An opinion document hash already existsThe same decision becomes a duplicate opinionCheck the hash before creation and again before save
A RECAP opinion has no usable text or valid normalized nameThe opinion keeps weak or incomplete case namingKeep docket-derived names as the fallback and record the enrichment failure
A bulk PACER session expires or requests run too quicklyDockets or final documents remain incompleteRenew sessions during long runs and throttle queued work
A SCOTUS probe advances its ingested watermark before save and enqueue finishA docket range can be skipped after a crashAdvance the known watermark only after each serial completes
Participant roles or firms are read outside the current docketA case page shows false representation dataScope role and firm associations to the displayed docket
A citation has several candidatesThe corpus creates a false legal linkKeep the citation ambiguous and use lookup
A citation has no candidateReaders lose a path to later matching dataStore an unmatched citation for retry
Citation data changes without search refreshSearch and case views show stale legal relationshipsReindex related citation fields
A cluster is replaced without a redirectionExisting public links stop at a missing casePreserve a replacement redirect or return a deliberate gone response

Key files

FileWhy to read it
cl/…/models.pyDefines the court, docket, cluster, opinion, content, citation, and citation-relationship model.
cl/…/tasks.pyShows PACER and RECAP acquisition, opinion promotion, case-name enrichment, and the handoff from source documents to enrichment.
cl/…/kessler_ilnb.pyIllustrates a tagged PACER batch that acquires Illinois bankruptcy dockets and selected documents.
cl/…/centralia.pyShows how structured opinion text becomes one or more opinions after quality checks.
cl/…/extract_structured_opinions.pyShows the controlled batch path for structured opinion extraction.
cl/…/probe_scotus_dockets_daemon.pyShows how new SCOTUS docket records are discovered and resumed after interruption.
cl/…/import_tn.pyIllustrates a direct court corpus entering the shared opinion model.
cl/…/utils.pyShows shared document comparison, case matching, name merging, citation creation, and probe progression rules.
cl/…/match_citations.pyShows how text references become known, ambiguous, or unmatched case references.
cl/…/annotate_citations.pyShows how citation results become public links or safe non-links in opinion text.
cl/…/group_parentheticals.pyShows how repeated citation summaries become compact groups for readers.
cl/…/utils.pyShows text-source selection, case-law filtering, citation chunking, and count updates.
cl/…/views.pyShows the public case boundary, docket participant data, citation views, summaries, and related-case views.
cl/…/utils.pyShows shared docket context and the normalized data shape for parties, attorneys, firms, roles, and criminal charges.
cl/…/docket_page.htmlShows the shared docket page structure that connects entries, parties, and other docket tabs.
cl/…/docket_parties.html and cl/…/v2_docket_parties.htmlShow the two public presentations of the same docket participant data.
cl/…/documents.pyShows how clusters and opinions become published search records.