This prompt is designed for document intelligence engineers and legal or academic data pipeline operators who need to extract footnotes, endnotes, and their corresponding in-text anchors from structured documents such as contracts, court filings, academic papers, and regulatory submissions. The core job-to-be-done is producing a machine-readable, linked mapping of note-body pairs with page locations and cross-reference integrity checks. The ideal user has access to pre-parsed text with page metadata and needs structured JSON output for downstream ingestion into a document database, search index, or review platform.
Prompt
Footnote and Endnote Extraction Prompt

When to Use This Prompt
Define the extraction job, the ideal user, required inputs, and the boundaries where this prompt should not be applied.
Use this prompt when the document's logical structure is already recovered—meaning you have clean text blocks with page numbers—and you need to isolate the note apparatus from the body text. It is appropriate for single-document processing where the note format follows standard conventions (superscript numerals, bracketed numbers, or symbolic references). The prompt expects [INPUT] to contain the full document text with page markers, and it will produce a JSON array of note objects, each containing the anchor text span, the note body, the page location of both, and a cross-reference status flag. Do not use this prompt for handwritten notes, scanned documents without OCR, or documents where notes are inline parentheticals rather than separated footnotes or endnotes.
This prompt is not a substitute for a full document layout parser. It assumes that text has already been linearized and that page boundaries are known. If your document has multi-column layouts, sidebars, or complex floating elements, you should first apply a reading-order recovery prompt to establish a reliable text sequence. Additionally, this prompt does not handle image-based notes or notes embedded in tables—those require a multimodal extraction approach. For high-stakes legal or regulatory use cases, always pair this prompt with a validation harness that checks for orphaned notes (note bodies without anchors) and broken references (anchors pointing to non-existent notes). Human review should be triggered when the cross-reference integrity check fails or when confidence scores fall below your operational threshold.
Use Case Fit
Where the Footnote and Endnote Extraction Prompt works well and where it introduces risk. Use these cards to decide if this prompt fits your document pipeline before investing in integration.
Good Fit: Structured Legal and Academic Documents
Use when: documents contain explicit footnote/endnote markers (superscript, brackets) and a dedicated notes section. The prompt reliably pairs anchors with note bodies when the document follows predictable numbering. Guardrail: validate that every extracted note has a corresponding body-text anchor and vice versa.
Bad Fit: Scanned Documents with Noisy OCR
Avoid when: footnotes are rendered as marginalia, the OCR output merges note text with body text, or superscript markers are lost during text extraction. The prompt cannot recover structure that the text layer does not preserve. Guardrail: preprocess with layout-aware OCR and validate marker detection rates before routing to this prompt.
Required Inputs
What you must provide: full document text with preserved page breaks, explicit page-number annotations, and a clear delimiter between body content and the notes section. Guardrail: if page metadata is missing, the prompt cannot produce reliable page-location fields. Run a precheck for page-break tokens before calling the extraction prompt.
Operational Risk: Orphaned Notes and Broken Anchors
What to watch: notes without matching body-text references, or body-text markers that point to nonexistent notes. This breaks downstream linking and citation integrity. Guardrail: add a post-extraction validation step that flags orphaned notes and unresolved anchors, and route flagged documents to human review.
Operational Risk: Cross-Reference Drift Across Page Breaks
What to watch: notes that span page breaks may be split, duplicated, or misattributed to the wrong page. Guardrail: implement a continuity check that merges note fragments across page boundaries and verifies that each note body is assigned to exactly one page location.
Not a Fit: Real-Time or Streaming Text
Avoid when: the document is incomplete, streaming, or lacks a defined notes section. The prompt assumes a complete document with a clear body-notes boundary. Guardrail: buffer the full document before extraction, or use a separate incremental-marker detection prompt for partial documents.
Copy-Ready Prompt Template
A reusable prompt for extracting footnotes, endnotes, and their body-text anchors into linked, validated pairs.
This prompt template is designed to be dropped into a document processing pipeline where the input is a single, plain-text representation of a document containing footnotes or endnotes. It instructs the model to identify every note, locate its corresponding anchor in the body text, and return a structured array of linked pairs. The template uses square-bracket placeholders for all variable inputs, allowing you to adapt it to different document formats, output schemas, and risk tolerances without rewriting the core instruction logic.
textYou are a precise document structure extraction engine. Your task is to extract all footnotes and endnotes from the provided document text, link each note to its corresponding anchor in the body text, and return the results in a strict JSON format. ## INPUT Document text: [INPUT_TEXT] ## OUTPUT SCHEMA Return a single JSON object with a key "notes" containing an array of note objects. Each note object must have the following fields: - "note_id": string, a unique identifier for the note (e.g., "fn1", "en12"). - "note_type": string, either "footnote" or "endnote". - "note_text": string, the full text of the note, cleaned of any leading markers. - "anchor_text": string, the exact text span in the body that references this note (e.g., "¹", "[1]", "see note 3"). - "anchor_context": string, a 100-character window of body text surrounding the anchor for verification. - "page_number": integer or null, the page number where the note appears, if detectable from the text. - "cross_references": array of strings, a list of other note_ids referenced within this note's text. - "confidence": number between 0.0 and 1.0, your confidence that the anchor-note pairing is correct. ## CONSTRAINTS [CONSTRAINTS] ## EXAMPLES [EXAMPLES] ## RISK LEVEL [RISK_LEVEL] ## INSTRUCTIONS 1. Scan the entire document to identify all footnote and endnote markers in the body text and the notes themselves. 2. For each note, find its exact anchor in the body text. If an anchor cannot be found, set "anchor_text" to null and "confidence" to 0.0. 3. If a note references another note, list its ID in "cross_references". 4. If the document contains both footnotes and endnotes, distinguish them accurately. 5. Do not invent notes or anchors. If the text is ambiguous, set "confidence" below 0.5 and note the ambiguity in a separate "warnings" array at the top level of the JSON output.
To adapt this template, replace the placeholders with your specific requirements. For [CONSTRAINTS], add rules like "Ignore notes in headers and footers" or "Treat roman numeral markers as endnotes." For [EXAMPLES], provide one or two few-shot demonstrations of the exact input-output mapping you expect, especially for edge cases like in-text citations that are not notes. The [RISK_LEVEL] placeholder should be set to "high" for legal or regulatory documents, which will trigger a post-processing validation step in your harness to check for orphaned notes and broken cross-references before the output is accepted.
Prompt Variables
Required and optional inputs for the Footnote and Endnote Extraction Prompt. Validate each placeholder before sending the prompt to avoid silent extraction failures.
| Placeholder | Purpose | Example | Validation Notes |
|---|---|---|---|
[DOCUMENT_TEXT] | Full text of the document from which footnotes and endnotes will be extracted | See attached contract. 1 This is a footnote. SECTION 2... | Must be non-empty string. Check for encoding issues (e.g., mojibake) before passing. Minimum 50 characters recommended. |
[NOTE_TYPE] | Specifies whether to extract footnotes, endnotes, or both | footnotes | Must be one of: footnotes, endnotes, both. Enum validation required. Case-insensitive match recommended. |
[PAGE_NUMBERING_MODE] | Indicates whether page numbers are embedded in text, provided separately, or absent | embedded | Must be one of: embedded, provided, absent. If provided, [PAGE_MAP] becomes required. |
[PAGE_MAP] | Mapping of page break indicators to page numbers when not embedded in text | {"--- Page 1 ---": 1, "--- Page 2 ---": 2} | Required if [PAGE_NUMBERING_MODE] is provided. Must be valid JSON object with string keys and integer values. Null allowed otherwise. |
[ANCHOR_FORMAT] | Expected format of footnote/endnote anchors in body text | superscript numbers in square brackets | Free-text description. Common values: superscript numbers, bracketed numbers, asterisk symbols, roman numerals. Affects extraction regex and model attention. |
[OUTPUT_SCHEMA] | Target JSON schema for extracted note-body pairs | {"notes": [{"note_id": "1", "anchor_text": "", "note_text": "", "page": 1, "note_type": "footnote", "cross_references": []}]} | Must be valid JSON Schema or example structure. Validate parseable JSON before prompt assembly. Include required fields: note_id, anchor_text, note_text, page, note_type. |
[CONFIDENCE_THRESHOLD] | Minimum confidence score (0.0-1.0) for auto-accepting extracted pairs | 0.85 | Must be float between 0.0 and 1.0. Pairs below threshold should route to human review queue. Null allowed if no threshold desired. |
[MAX_NOTES] | Upper bound on number of notes to extract; prevents runaway extraction on corrupted documents | 500 | Must be positive integer. Set based on document length expectations. Exceeding this count should trigger a warning and partial-result return. |
Implementation Harness Notes
How to wire the footnote and endnote extraction prompt into a production document processing pipeline.
The footnote and endnote extraction prompt is designed to be called after the main body text has been extracted and segmented by page. In a production pipeline, you should pass the full document text with page markers as [INPUT] and a strict JSON schema as [OUTPUT_SCHEMA]. The model must return a list of note objects, each containing the note text, its anchor symbol or number, the page where the note appears, and the page and approximate span of the body-text anchor. This output is not the final product—it is a structured intermediate payload that must be validated before ingestion into a document index or review system.
Wire the prompt into your application with a post-processing validator that checks for three critical failure modes: orphaned notes (notes with no matching body anchor), broken cross-references (body anchors that point to non-existent notes), and duplicate anchor symbols on the same page. Implement a retry loop that re-submits failed pages with the validator's error messages appended as [CONSTRAINTS]. For high-stakes legal or regulatory documents, route any page with unresolved validation errors to a human review queue. Log every extraction run with the document ID, page range, model version, prompt version, validator results, and human-review decisions. This audit trail is essential for compliance teams who need to prove extraction completeness.
Model choice matters here. Use a model with strong instruction-following and long-context handling, such as GPT-4o or Claude 3.5 Sonnet, because footnote sections often span many pages and the model must maintain anchor-note linkage across long distances. Avoid small or local models for documents exceeding 50 pages unless you chunk the document into overlapping sections and reconcile the outputs with a deduplication step. Do not rely on the prompt alone for cross-reference integrity—always run the validator. The prompt is the extraction engine; the harness is the safety net.
Expected Output Contract
Defines the exact fields, types, and validation rules for the Footnote and Endnote Extraction Prompt output. Use this contract to build downstream parsers, database schemas, and automated validation checks.
| Field or Element | Type or Format | Required | Validation Rule |
|---|---|---|---|
notes | Array of Note Objects | Must be a JSON array. Empty array is valid if no notes found. Schema check: validate each element against Note Object contract. | |
notes[].note_id | String | Must be unique within the array. Format: 'fn-{page}-{sequence}' or 'en-{page}-{sequence}'. Regex: ^(fn|en)-\d+-\d+$ | |
notes[].note_type | Enum: 'footnote' | 'endnote' | Must be one of the two allowed values. Case-sensitive. Reject any other string. | |
notes[].note_text | String | Must not be empty or whitespace-only. Length > 0. Trim leading/trailing whitespace before validation. | |
notes[].anchor_text | String or null | If present, must be a non-empty string representing the body-text phrase linked to this note. Null allowed when anchor is a symbol or superscript number only. | |
notes[].page_number | Integer or null | If present, must be a positive integer. Null allowed if page number cannot be determined. Validate: page_number > 0. | |
notes[].cross_references | Array of Strings | If present, each element must be a non-empty string referencing another note_id or section label. Empty array allowed. No orphaned references: each value must match an existing note_id or be flagged for human review. | |
notes[].confidence | Number between 0.0 and 1.0 | Must be a float. Range check: 0.0 <= confidence <= 1.0. Values below [CONFIDENCE_THRESHOLD] should trigger human review or retry. |
Common Failure Modes
What breaks first when extracting footnotes and endnotes from legal and academic documents, and how to guard against it.
Orphaned Notes Without Body Anchors
What to watch: The model extracts footnote text but fails to link it to any in-body anchor, producing floating notes with no source context. This happens when superscript markers are small, faint, or misread by OCR. Guardrail: Add a post-extraction validation step that rejects any note record missing a body_anchor_text field. Flag orphaned notes for human review and log the page number for manual reconciliation.
Broken Cross-Reference Integrity
What to watch: Notes that reference other notes or sections (e.g., 'see note 14 supra') produce broken links when the target note was extracted with a different ID or missed entirely. Guardrail: Build a reference graph during extraction and validate that every cross-reference target exists in the output. Emit a cross_reference_status field with resolved, unresolved, or circular values for downstream handling.
Page Boundary Note Splitting
What to watch: Long footnotes that span page breaks get split into two separate note records, each incomplete. The model treats the continuation as a new note because the page delimiter resets context. Guardrail: Implement a continuation-detection heuristic that checks if a note at the top of a page lacks a body anchor and begins mid-sentence. Merge candidates with the previous page's last unterminated note before final output.
Endnote vs. Footnote Classification Confusion
What to watch: The model misclassifies endnotes as footnotes (or vice versa) when documents use both, producing incorrect note_type values and mixing location metadata. This is common in academic papers with chapter-end notes plus page footnotes. Guardrail: Add explicit location-based rules in the prompt: notes at page bottom are footnotes, notes at chapter or document end are endnotes. Validate that note_location and note_type are consistent before ingestion.
Superscript Marker Misattribution
What to watch: When multiple superscript markers appear close together (e.g., 'text¹²³'), the model assigns the wrong note to the wrong anchor, scrambling the note-body pairing. Guardrail: Require the model to extract the exact anchor character sequence and the surrounding body-text window. Add a co-location check: if multiple anchors appear within 50 characters, flag the record with anchor_proximity_risk: true for human sampling.
Note Content Truncation at Special Characters
What to watch: The model stops extracting note text at the first line break, bracket, or special character, producing truncated note bodies that lose citations, parentheticals, or multi-paragraph content. Guardrail: Explicitly instruct the model to capture the full note text until the next note marker or section boundary. Add a minimum-length check: flag any note body under 20 characters for review unless it's a known short-form reference.
Evaluation Rubric
Test output quality before shipping the Footnote and Endnote Extraction Prompt. Each criterion targets a specific failure mode in production document processing pipelines.
| Criterion | Pass Standard | Failure Signal | Test Method |
|---|---|---|---|
Anchor-Note Pairing Completeness | Every extracted footnote or endnote has exactly one matching body-text anchor reference | Orphaned notes with no anchor or anchors with no note body | Count extracted anchors and notes; assert counts match and every ID appears in both sets |
Cross-Reference Integrity | All internal cross-references within notes resolve to valid note IDs or document sections | Broken reference targets or hallucinated note IDs not present in the document | Parse reference targets from note text; validate each target exists in the extracted note ID set or document section list |
Page Location Accuracy | Page number for each anchor and note matches source document within ±1 page tolerance | Page numbers outside tolerance or null page for notes with visible page markers | Spot-check 20% of extracted page numbers against source PDF page rendering |
Note Body Text Fidelity | Extracted note text matches source verbatim with no truncation, hallucination, or paragraph merge | Missing sentences, merged adjacent notes, or invented content in note body | Diff extracted note text against ground-truth note text for a golden set of 10 documents |
Null Handling for Missing Fields | Fields absent from source document are null, not empty strings or hallucinated defaults | Empty string for missing note number or invented page reference when source lacks pagination | Schema validation asserting null type for optional fields when source evidence is absent |
Duplicate Note Detection | No duplicate note entries with identical or near-identical body text and anchor references | Same footnote body extracted twice with different auto-generated IDs | Hash note body text; assert no collisions within a single document extraction output |
Confidence Flag Accuracy | Low-confidence extractions correctly flagged when OCR is degraded or anchor-note link is ambiguous | High-confidence flag on a note with illegible source text or ambiguous anchor mapping | Review all low-confidence flags against source documents; assert each has visible degradation or ambiguity |
Schema Conformance | Output validates against the defined JSON schema with all required fields present and correctly typed | Missing required fields, wrong types, or extra undeclared fields in output | Run automated JSON Schema validation on extraction output for every document in the test corpus |
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Adapt This Prompt
How to adapt
Start with the base extraction prompt and a single representative document. Use a simple JSON output schema with notes as an array of {note_id, anchor_text, note_text, page} objects. Skip cross-reference integrity checks initially—focus on whether the model can find notes and anchors at all.
Add a lightweight post-processing script that checks for:
- Empty
note_textfields - Duplicate
note_idvalues pagevalues outside the document's known page range
Watch for
- The model confusing margin comments or parenthetical citations with footnotes
- Anchors extracted without their corresponding note body (and vice versa)
- Page numbers off by one when the model counts from zero versus the document's printed numbering

About the author
Prasad Kumkar
CEO & MD, Inference Systems
Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.
His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us