EN
Sign in Publish
contextetech /

JSON schema: extract a U.S. invoice

v1
Target model : General (any model) English License: MIT Published on updated 1 hour ago 0 uses

JSON Schema to extract a U.S. invoice with an LLM: vendor, invoice number, dates, line items, subtotal, sales tax and total in USD.

Extract the invoice data. Amounts are plain numbers in U.S. dollars, without the $ sign. If a field is missing, leave it out: never invent it.

JSON Schema

{
  "type": "object",
  "required": [
    "vendor",
    "invoice_date",
    "total"
  ],
  "properties": {
    "total": {
      "type": "number"
    },
    "vendor": {
      "type": "string",
      "description": "Legal name of the vendor"
    },
    "currency": {
      "enum": [
        "USD"
      ],
      "type": "string"
    },
    "due_date": {
      "type": "string",
      "format": "date"
    },
    "subtotal": {
      "type": "number"
    },
    "sales_tax": {
      "type": "number",
      "description": "Sales tax amount, 0 if none"
    },
    "line_items": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "description",
          "amount"
        ],
        "properties": {
          "amount": {
            "type": "number"
          },
          "quantity": {
            "type": "number"
          },
          "unit_price": {
            "type": "number"
          },
          "description": {
            "type": "string"
          }
        }
      }
    },
    "invoice_date": {
      "type": "string",
      "format": "date",
      "description": "Issue date (YYYY-MM-DD)"
    },
    "invoice_number": {
      "type": "string"
    }
  }
}

Output example

{
  "vendor": "Bright Print Co.",
  "invoice_number": "INV-2026-0412",
  "invoice_date": "2026-09-15",
  "due_date": "2026-10-15",
  "line_items": [
    {
      "description": "Business cards x500",
      "quantity": 1,
      "unit_price": 80.0,
      "amount": 80.0
    },
    {
      "description": "Flyers 5.5x8.5 x1000",
      "quantity": 1,
      "unit_price": 120.0,
      "amount": 120.0
    }
  ],
  "subtotal": 200.0,
  "sales_tax": 17.25,
  "total": 217.25,
  "currency": "USD"
}

Community

No comments yet. Share your feedback, it will help the next person.