address-parsing
Published
Public
in @structured-extraction

Parse an unstructured address string into structured components — recipient, street, unit, city, state/region, postal code, and country. Optional country hint guides format expectations. Returns a confidence score.

address-parsing

Split a messy, free-form address string into clean structured components — recipient, street_address, unit, city, state_region, postal_code, country — with a confidence score. Handles the inconsistent, single-line addresses that regexes choke on.

Entrypoints

EntrypointRendersInputs
systemPromptInstructions, component list + embedded schemaoptional countryHint
userPromptThe delimited address stringaddress

Variables

  • address (string, required) — the unstructured address to parse.
  • countryHint (string, optional) — a country name or ISO code (e.g. "US", "United Kingdom") to guide format expectations when the string is ambiguous or omits the country.

Output

{
  "reasoning": "Comma-delimited US address; unit split from the street line, state and ZIP recognized.",
  "components": {
    "recipient": "Acme Corp",
    "street_address": "350 Fifth Avenue",
    "unit": "Suite 2100",
    "city": "New York",
    "state_region": "NY",
    "postal_code": "10118",
    "country": "United States"
  },
  "confidence": 0.92
}
  • reasoning is emitted first (house convention).
  • Missing components are null — the prompt is told never to guess a postal code, city, or country that isn't present. The one licensed exception: country may be filled from countryHint.
  • confidence is self-reported and ⚠️ not calibrated — a rough signal for flagging addresses that need review, not a probability.

House conventions

  • Triple-mustache for address so &, #, and other characters survive.
  • <address> delimiters around the input.
  • Strict schemaadditionalProperties: false, confidence bounded 0–1.

Notes

Verified by local render with and without countryHint. Suggested default claude-sonnet-4-6 at temperature: 0. For deliverability-critical use, follow up with a postal-validation API — this prompt structures an address, it does not verify it exists.

@sufleur/