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
- Query Farm hosting
- Available · $10/month organization minimum
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);
| 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.
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;
INSTALL vgi FROM community;
LOAD vgi;
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
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);
Run the connector on a server you manage. You operate the service and choose who can connect.
1. Deploy the connector on your server
Follow the connector’s deployment instructions. Use its supported HTTP transport, or launch it remotely over SSH. The connection guide explains both options.
2. Install the vgi extension
Run this in your SQL client. On DuckDB, keep FROM query_farm on LOAD in later sessions.
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;
INSTALL vgi FROM community;
LOAD vgi;
3. Attach the connector
For an HTTP deployment, replace the example URL with your endpoint. Add the authentication options your deployment requires. For SSH, use the SSH connection instructions.
ATTACH 'postal' AS postal
(TYPE vgi, LOCATION 'https://your-connector.example.com');
4. Run a query
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);
Query Farm operates libpostal for your team. Hosting has a $10 monthly minimum per organization; usage counts toward it. From $2.97 per instance-month ($10 monthly minimum).
1. Create your hosted connector
Open the console, choose your organization and deployment size, and add any service credentials there.
2. Install the vgi extension
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;
INSTALL vgi FROM community;
LOAD vgi;
3. Attach your deployment
Copy the ATTACH statement from your deployment in the console and run it in DuckDB or Haybarn. Use postal as the catalog alias for the query below.
4. Run a query
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);
Technical details
- Verified connector release
- v0.5.0
- Engine
- 2.0.1
- VGI protocol
- 3.4.0
- Verified on
- December 1, 2026
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
Parse, standardize, and normalize free-form postal addresses from anywhere in the world directly in DuckDB SQL — turn a messy one-line address string into clean, structured components (house number, road, unit, city, state, postcode, country) without leaving your query.
The postal catalog brings libpostal — the open-source statistical address parser trained on OpenStreetMap and open address data — to SQL. It is built for data engineers, analysts, and anyone doing geocoding pre-processing, address standardization, record linkage, entity resolution, or deduplication over customer, shipping, or location data. Because libpostal is trained on real addresses from OpenStreetMap across hundreds of countries and languages, it handles international formats, transliteration, and local abbreviations far better than hand-written regular expressions or fixed format rules.
Under the hood this worker wraps libpostal's C library through its official Python binding, pypostal, and exposes it over DuckDB's VGI interface. libpostal does two core things: it parses an address — using a sequence model to tag each token with a component label — and it expands/normalizes abbreviations into canonical forms (for example St → street, E → east, Rd → road), which is what makes two differently written versions of the same address comparable. All output is lower-cased; an empty string yields an empty result and NULL yields NULL, so the functions compose cleanly inside larger queries.
Key concepts
- Parsing turns a one-line address into labeled components (house number, road, unit, city, state, postcode, country, and more). Labels are statistical and best-effort — a borough can come back as a city district rather than a city — so treat them as a strong signal, not a strict schema.
- Normalization / expansion rewrites abbreviations into canonical, fully-spelled-out forms and can return several valid variants for an ambiguous token; two addresses match when their expansion sets overlap.
When to reach for it
Use this catalog for geocoding pre-processing, address standardization, record linkage, entity resolution, and deduplication over customer, shipping, or location data — anywhere you need messy free-form addresses made comparable directly in SQL, without shipping data to an external service.
Learn more from the libpostal source repository and its installation and usage documentation.
Catalog
Everything postal exposes once attached — read straight from the worker's
released build.
main 1 table · 10 functions
libpostal address parsing, component extraction, and normalization functions
Schema 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;
address_labels
Every component label libpostal can emit, one per row (discovery table).
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;
address_city (text VARCHAR)
The libpostal 'city' component of an address, or NULL if absent
Extract just the city (locality) from an address.
SELECT postal.main.address_city('1600 Pennsylvania Ave NW, Washington, DC 20500');
address_country (text VARCHAR)
The libpostal 'country' component of an address, or NULL if absent
Extract the country from an international address.
SELECT postal.main.address_country('10 Downing St, London SW1A 2AA, United Kingdom');
address_house_number (text VARCHAR)
The libpostal 'house_number' component of an address, or NULL if absent
Extract just the house (street) number from an address.
SELECT postal.main.address_house_number('781 Franklin Ave, Brooklyn, NY 11216');
address_postcode (text VARCHAR)
The libpostal 'postcode' (ZIP) component of an address, or NULL if absent
Extract just the postcode (ZIP) from an address.
SELECT postal.main.address_postcode('781 Franklin Ave, Brooklyn, NY 11216');
address_road (text VARCHAR)
The libpostal 'road' (street) component of an address, or NULL if absent
Extract just the road (street name) from an address.
SELECT postal.main.address_road('781 Franklin Ave, Brooklyn, NY 11216');
address_state (text VARCHAR)
The libpostal 'state' (province/region) component of an address, or NULL if absent
Extract the state/province from an address (output is lower-cased).
SELECT postal.main.address_state('781 Franklin Ave, Brooklyn, NY 11216');
address_unit (text VARCHAR)
The libpostal 'unit' (apartment/suite) component of an address, or NULL if absent
Extract the unit (apartment/suite) from an address.
SELECT postal.main.address_unit('Apt 5B, 120 E 96th St, New York, NY 10128');
expand_address (text VARCHAR)
Normalize an address into a LIST of libpostal expansions (e.g. 'St' -> 'street', 'E' -> 'east'). Empty string -> empty list; NULL -> NULL.
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;
parse_address (text VARCHAR)
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.
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'];
parse_address_components (text VARCHAR)
Parse an address into one (label, value) row per libpostal component
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;
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
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.
Related workers
Geocode
Maps & places
Turn latitude/longitude into city, country, admin region and timezone offline, plus haversine distance
Overture Maps
Maps & places
Explore buildings, places, roads, and administrative boundaries within any region
ArcGIS
Maps & places
Live ArcGIS feature queries, server summaries and raster sampling from service URLs worldwide