Skip to content

libpostal

Parse and normalize international street addresses into house number, road, city, postcode and more

Connector software
Free and open source
Service credentials
Not needed
Use with an agent

Install the Orchard skill in your project to help your agent find connectors, configure them, and verify SQL results.

npx skills add Query-farm/vgi-skills --skill orchard

Copy this request into your coding agent to get started.

Use https://query.farm/products/orchard/connectors/libpostal/index.md to help me query libpostal with DuckDB or Haybarn 2.0.1 and VGI protocol 3.4. Ask only for missing details about the result I need or whether I want local execution, self-hosting or Query Farm hosting. Check the connector's actual hosting availability, credentials and input requirements. Read one format of each needed reference and the exact object declarations before writing SQL. Use a released connector, and distinguish a saved example result from anything you actually execute. If you cannot run the query, tell me what remains to verify.

Turn street addresses into structured fields

Example output · captured
Connector release
v0.5.0
Engine
2.0.1
VGI protocol
3.4.0
SELECT address, postal.main.parse_address(address) AS components
FROM (VALUES ('1600 Pennsylvania Ave NW, Washington, DC 20500'), ('10 Downing Street, London SW1A 2AA')) AS input(address);
Result
address components
1600 Pennsylvania Ave NW, Washington, DC 20500 {"house_number": "1600", "road": "pennsylvania ave nw", "city": "washington", "…
10 Downing Street, London SW1A 2AA {"house_number": "10", "road": "downing street", "city": "london", "postcode": …

Quick start

Choose where to run libpostal, then follow the steps below.

The connector runs alongside DuckDB or Haybarn. No Query Farm account is needed.

1. Install the vgi extension

Run this in your SQL client. On DuckDB, keep FROM query_farm on LOAD in later sessions.

setup.sql
SET allow_extension_repositories = 'allowed';

CREATE EXTENSION REPOSITORY IF NOT EXISTS query_farm
    WITH PREFIX 'https://duckdb-extensions.query.farm';

INSTALL vgi FROM query_farm;
LOAD vgi FROM query_farm;

2. Attach the connector

Attach the signed image

Needs Docker, Podman or another OCI runtime. The extension runs the container and talks to it over stdio.

ATTACH 'postal' AS postal (
  TYPE vgi,
  LOCATION 'oci://ghcr.io/query-farm/vgi-libpostal:0.5.0'
);

3. Run a query

query.sql
SELECT address, postal.main.parse_address(address) AS components
FROM (VALUES ('1600 Pennsylvania Ave NW, Washington, DC 20500'), ('10 Downing Street, London SW1A 2AA')) AS input(address);
More example queries →
Technical details
Verified connector release
v0.5.0
Engine
2.0.1
VGI protocol
3.4.0
Verified on
December 1, 2026
Release notes on GitHub
Pin a version for production

When running the connector yourself, keep a specific release until you’re ready to upgrade. Replace the ATTACH statement above with this one and follow the same extension and credential setup.

Attach the signed image

Needs Docker, Podman or another OCI runtime. The extension runs the container and talks to it over stdio.

ATTACH 'postal' AS postal (
  TYPE vgi,
  LOCATION 'oci://ghcr.io/query-farm/vgi-libpostal:0.5.0'
);

Overview

Parse + normalize international postal addresses (libpostal) for SQL

Catalog

Everything postal exposes once attached — read straight from the worker's released build.

postal 1 schema
main 1 table · 10 functions

libpostal address parsing, component extraction, and normalization functions

Schema examples (9)
Examples (9)

Parse a US address into a MAP of libpostal components.

SELECT postal.main.parse_address('1600 Pennsylvania Ave NW, Washington, DC 20500');

Pull just the postcode out of a parsed UK address.

SELECT postal.main.parse_address('10 Downing St, London SW1A 2AA, UK')['postcode'];

Normalize an abbreviated address into one expansion per row.

SELECT UNNEST(postal.main.expand_address('120 E 96th St'));

Extract a single component (the postcode) inline.

SELECT postal.main.address_postcode('781 Franklin Ave, Brooklyn, NY 11216');
5 more examples

Long-format parse: one (label, value) row per component.

SELECT label, value
FROM postal.main.parse_address_components('781 Franklin Ave, Brooklyn, NY 11216')
ORDER BY label;

List the vocabulary of component labels libpostal can emit.

SELECT label FROM postal.main.address_labels() ORDER BY label;

Find duplicate customer addresses: block candidate pairs on the extracted postcode, then match when their libpostal normalized expansions overlap (pairs 1-2 and 3-4 match; 120 vs 130 E 96th St does not).

WITH customers(id, addr) AS (VALUES (1, '120 E 96th St, New York, NY 10128'), (2, '120 East 96th Street, New York NY 10128'), (3, '781 Franklin Ave, Brooklyn, NY 11216'), (4, '781 Franklin Avenue, Brooklyn NY 11216'), (5, '130 E 96th St, New York, NY 10128')), keyed AS (SELECT id, addr, postal.main.address_postcode(addr) AS postcode, postal.main.expand_address(addr) AS forms FROM customers) SELECT a.id AS id_a, b.id AS id_b, a.postcode
FROM keyed AS a
JOIN keyed AS b ON a.postcode = b.postcode AND a.id < b.id AND list_has_any(a.forms, b.forms)
ORDER BY id_a, id_b;

Parse an address into long-format components and normalize each value with expand_address (e.g. road 'pennsylvania ave nw' -> 'pennsylvania avenue northwest', state 'dc' -> 'district of columbia').

SELECT label, value, postal.main.expand_address(value) AS normalized
FROM postal.main.parse_address_components('1600 Pennsylvania Ave NW, Washington, DC 20500')
ORDER BY label;

Profile a batch of addresses: for every label libpostal can emit, count how many addresses it was parsed out of (0 for labels none of them contain).

WITH addrs(addr) AS (VALUES ('781 Franklin Ave, Brooklyn, NY 11216'), ('Apt 5B, 120 E 96th St, New York, NY 10128'), ('10 Downing St, London SW1A 2AA, United Kingdom')), found AS (SELECT DISTINCT addr, unnest(map_keys(postal.main.parse_address(addr))) AS label FROM addrs) SELECT l.label, count(f.addr) AS addresses_with_label
FROM postal.main.address_labels AS l
LEFT JOIN found AS f USING (label)
GROUP BY l.label
ORDER BY addresses_with_label DESC, l.label;
Tables
address_labels 5 examples1 col

Every component label libpostal can emit, one per row (discovery table).

Columns
labelnot null VARCHAR
A component label libpostal can emit, e.g. road, city, state, postcode, country.
ConstraintsPRIMARY KEY (label)
Examples (5)

List every component label libpostal can emit.

SELECT label FROM postal.main.address_labels ORDER BY label;

Count how many component labels libpostal recognizes.

SELECT count(*) AS label_count FROM postal.main.address_labels;

Profile a batch of addresses: for every label libpostal can emit, count how many addresses it was parsed out of (0 for labels none of them contain).

WITH addrs(addr) AS (VALUES ('781 Franklin Ave, Brooklyn, NY 11216'), ('Apt 5B, 120 E 96th St, New York, NY 10128'), ('10 Downing St, London SW1A 2AA, United Kingdom')), found AS (SELECT DISTINCT addr, unnest(map_keys(postal.main.parse_address(addr))) AS label FROM addrs) SELECT l.label, count(f.addr) AS addresses_with_label
FROM postal.main.address_labels AS l
LEFT JOIN found AS f USING (label)
GROUP BY l.label
ORDER BY addresses_with_label DESC, l.label;
2 more examples
SELECT count(*) AS label_count FROM postal.main.address_labels();
SELECT label FROM postal.main.address_labels() ORDER BY label;
Link
Scalar functions
address_city (text VARCHAR) 1 example

The libpostal 'city' component of an address, or NULL if absent

Arguments
text VARCHAR
Address text to parse.
ReturnsVARCHAR
Example

Extract just the city (locality) from an address.

SELECT postal.main.address_city('1600 Pennsylvania Ave NW, Washington, DC 20500');
Link
address_country (text VARCHAR) 1 example

The libpostal 'country' component of an address, or NULL if absent

Arguments
text VARCHAR
Address text to parse.
ReturnsVARCHAR
Example

Extract the country from an international address.

SELECT postal.main.address_country('10 Downing St, London SW1A 2AA, United Kingdom');
Link
address_house_number (text VARCHAR) 1 example

The libpostal 'house_number' component of an address, or NULL if absent

Arguments
text VARCHAR
Address text to parse.
ReturnsVARCHAR
Example

Extract just the house (street) number from an address.

SELECT postal.main.address_house_number('781 Franklin Ave, Brooklyn, NY 11216');
Link
address_postcode (text VARCHAR) 1 example

The libpostal 'postcode' (ZIP) component of an address, or NULL if absent

Arguments
text VARCHAR
Address text to parse.
ReturnsVARCHAR
Example

Extract just the postcode (ZIP) from an address.

SELECT postal.main.address_postcode('781 Franklin Ave, Brooklyn, NY 11216');
Link
address_road (text VARCHAR) 1 example

The libpostal 'road' (street) component of an address, or NULL if absent

Arguments
text VARCHAR
Address text to parse.
ReturnsVARCHAR
Example

Extract just the road (street name) from an address.

SELECT postal.main.address_road('781 Franklin Ave, Brooklyn, NY 11216');
Link
address_state (text VARCHAR) 1 example

The libpostal 'state' (province/region) component of an address, or NULL if absent

Arguments
text VARCHAR
Address text to parse.
ReturnsVARCHAR
Example

Extract the state/province from an address (output is lower-cased).

SELECT postal.main.address_state('781 Franklin Ave, Brooklyn, NY 11216');
Link
address_unit (text VARCHAR) 1 example

The libpostal 'unit' (apartment/suite) component of an address, or NULL if absent

Arguments
text VARCHAR
Address text to parse.
ReturnsVARCHAR
Example

Extract the unit (apartment/suite) from an address.

SELECT postal.main.address_unit('Apt 5B, 120 E 96th St, New York, NY 10128');
Link
expand_address (text VARCHAR) 3 examples

Normalize an address into a LIST of libpostal expansions (e.g. 'St' -> 'street', 'E' -> 'east'). Empty string -> empty list; NULL -> NULL.

Arguments
text VARCHAR
Address text to normalize.
ReturnsVARCHAR[]
Examples (3)

Normalized expansions of an abbreviated address.

SELECT postal.main.expand_address('120 E 96th St');

One normalized expansion per row.

SELECT UNNEST(postal.main.expand_address('120 E 96th St'));

Find duplicate customer addresses: block candidate pairs on the extracted postcode, then match when their libpostal normalized expansions overlap (pairs 1-2 and 3-4 match; 120 vs 130 E 96th St does not).

WITH customers(id, addr) AS (VALUES (1, '120 E 96th St, New York, NY 10128'), (2, '120 East 96th Street, New York NY 10128'), (3, '781 Franklin Ave, Brooklyn, NY 11216'), (4, '781 Franklin Avenue, Brooklyn NY 11216'), (5, '130 E 96th St, New York, NY 10128')), keyed AS (SELECT id, addr, postal.main.address_postcode(addr) AS postcode, postal.main.expand_address(addr) AS forms FROM customers) SELECT a.id AS id_a, b.id AS id_b, a.postcode
FROM keyed AS a
JOIN keyed AS b ON a.postcode = b.postcode AND a.id < b.id AND list_has_any(a.forms, b.forms)
ORDER BY id_a, id_b;
Link
parse_address (text VARCHAR) 2 examples

Parse an address into a MAP of libpostal components (road, city, state, postcode, country, house_number, unit, ...). Values are lower-cased; empty string -> empty map; NULL -> NULL.

Arguments
text VARCHAR
Address text to parse.
ReturnsMAP(VARCHAR, VARCHAR)
Examples (2)

Parse a US address into a component MAP.

SELECT postal.main.parse_address('1600 Pennsylvania Ave NW, Washington, DC 20500');

Pull the postcode out of the parsed map.

SELECT postal.main.parse_address('10 Downing St, London SW1A 2AA, UK')['postcode'];
Link
Table functions
parse_address_components (text VARCHAR) 10 examples

Parse an address into one (label, value) row per libpostal component

Arguments
text VARCHAR
Address text to parse.
Returns columns
label VARCHAR
libpostal component label (road, city, state, postcode, country, house_number, unit, ...).
value VARCHAR
The (lower-cased) component value.
Examples (10)

Long-format parse of a US address, one component per row.

SELECT label, value
FROM postal.main.parse_address_components('781 Franklin Ave, Brooklyn, NY 11216')
ORDER BY label;

Pull one component out by filtering on its label.

SELECT value
FROM postal.main.parse_address_components('1600 Pennsylvania Ave NW, Washington, DC 20500')
WHERE label = 'city';

Parse an address into long-format components and normalize each value with expand_address (e.g. road 'pennsylvania ave nw' -> 'pennsylvania avenue northwest', state 'dc' -> 'district of columbia').

SELECT label, value, postal.main.expand_address(value) AS normalized
FROM postal.main.parse_address_components('1600 Pennsylvania Ave NW, Washington, DC 20500')
ORDER BY label;
7 more examples
SELECT postal.main.parse_address('1600 Pennsylvania Ave NW, Washington, DC 20500');
SELECT postal.main.parse_address('10 Downing St, London SW1A 2AA, UK')['postcode'];
SELECT postal.main.expand_address('120 E 96th St');
SELECT postal.main.address_postcode('781 Franklin Ave, Brooklyn, NY 11216');
SELECT label FROM postal.main.address_labels() ORDER BY label;
WITH customers(id, addr) AS (VALUES (1, '120 E 96th St, New York, NY 10128'), (2, '120 East 96th Street, New York NY 10128'), (3, '781 Franklin Ave, Brooklyn, NY 11216'), (4, '781 Franklin Avenue, Brooklyn NY 11216'), (5, '130 E 96th St, New York, NY 10128')), keyed AS (SELECT id, addr, postal.main.address_postcode(addr) AS postcode, postal.main.expand_address(addr) AS forms FROM customers) SELECT a.id AS id_a, b.id AS id_b, a.postcode
FROM keyed AS a
JOIN keyed AS b ON a.postcode = b.postcode AND a.id < b.id AND list_has_any(a.forms, b.forms)
ORDER BY id_a, id_b;
WITH addrs(addr) AS (VALUES ('781 Franklin Ave, Brooklyn, NY 11216'), ('Apt 5B, 120 E 96th St, New York, NY 10128'), ('10 Downing St, London SW1A 2AA, United Kingdom')), found AS (SELECT DISTINCT addr, unnest(map_keys(postal.main.parse_address(addr))) AS label FROM addrs) SELECT l.label, count(f.addr) AS addresses_with_label
FROM postal.main.address_labels AS l
LEFT JOIN found AS f USING (label)
GROUP BY l.label
ORDER BY addresses_with_label DESC, l.label;
Link

Try these queries

Parse a US address into a MAP of libpostal components.

SELECT postal.main.parse_address('1600 Pennsylvania Ave NW, Washington, DC 20500')

Uses parse_address

Normalize an abbreviated address into one expansion per row.

SELECT UNNEST(postal.main.expand_address('120 E 96th St'))

Uses expand_address

Extract a single component (the postcode) inline.

SELECT postal.main.address_postcode('781 Franklin Ave, Brooklyn, NY 11216')

Uses address_postcode

Long-format parse: one (label, value) row per component.

SELECT label, value
FROM postal.main.parse_address_components('781 Franklin Ave, Brooklyn, NY 11216')
ORDER BY label

Uses parse_address_components

List the vocabulary of component labels libpostal can emit.

SELECT label FROM postal.main.address_labels() ORDER BY label

List every component label libpostal can emit.

SELECT label FROM postal.main.address_labels ORDER BY label

Uses address_labels

14 more examples in the Catalog, each listed under the table or function it uses.

Questions it can answer

Plain-English questions from the worker's agent test tasks. An AI agent with this catalog attached should answer each one with SQL.

  • What postal code does the address '781 Franklin Ave, Brooklyn, NY 11216' contain? Return just the postcode as a single value.
  • Extract the house (street) number from '1600 Pennsylvania Ave NW, Washington, DC 20500'. Return it as a single value.
  • Parse '1600 Pennsylvania Ave NW, Washington, DC 20500' into its address components and return the city.
  • Using the long-format component parser, what value is labeled 'road' for '781 Franklin Ave, Brooklyn, NY 11216'?
  • How many distinct address component labels can this worker's discovery function report?
  • When you normalize/expand the abbreviated address '120 E 96th St', is '120 east 96th street' one of the expansions it produces? Return a single boolean.

libpostal is an independent open-source connector from Query.Farm. It is not affiliated with, endorsed by or sponsored by the services, projects or organisations it works with. Product names, logos and trademarks belong to their respective owners.