# Split a URL into its parts

Shape / columns

A variant of [Parse nested values](https://meridian.online/operations/parse-nested-values).

Extract the host, path, query parameters or other parts of a URL, or encode and decode URL text.

Page: <https://meridian.online/operations/parse-nested-values/split-url-into-parts>

## Status

Runs as a SQL step.

arcform carries it as a `sql:` step today.

## The DuckDB step

split a URL into its parts, read a query parameter, and encode and decode URL text

```sql
CREATE TEMP TABLE urls AS SELECT * FROM (VALUES
  (1, 'https://shop.example.com:8080/a/b?q=red%20shoes&page=2#top'),
  (2, 'http://example.org'),
  (3, NULL)
) t(id, url);
CREATE TEMP TABLE result AS
WITH parts AS (
  SELECT id, regexp_extract(url, '^(?:([a-z][a-z0-9+.-]*):)?(?://([^/?#:]*)(?::(\d+))?)?([^?#]*)(?:\?([^#]*))?(?:#(.*))?$',
                            ['scheme', 'host', 'port', 'path', 'query', 'fragment']) AS p FROM urls)
SELECT id, p.*, url_decode(nullif(regexp_extract(p.query, '(?:^|&)q=([^&]*)', 1), '')) AS q_param,
       url_encode('red shoes & more') AS encoded
FROM parts;
SELECT * FROM result ORDER BY id;
SELECT CASE WHEN ((SELECT [scheme, host, port, path, query, fragment, q_param] FROM result WHERE id = 1) = ['https', 'shop.example.com', '8080', '/a/b', 'q=red%20shoes&page=2', 'top', 'red shoes'] AND (SELECT [scheme, host, path, query] FROM result WHERE id = 2) = ['http', 'example.org', '', ''] AND (SELECT q_param FROM result WHERE id = 2) IS NULL AND (SELECT encoded FROM result WHERE id = 1) = 'red%20shoes%20%26%20more' AND (SELECT count(*) FROM result WHERE id = 3 AND host IS NULL) = 1) THEN 'as expected' ELSE error('the URLs were not split into scheme, host, port, path, query and fragment, or the q parameter was not decoded, or text was not encoded') END AS verdict;
```

The statement builds its own data.

It needs nothing installed beyond DuckDB itself.

## What other tools call it

Meridian's classification; an independent blind rating agreed on 95.7% of 324 rows (variant, version 3).

- Bruin: [`bruin.get_url_host(field)`](https://getbruin.com/docs/bruin/assets/templating/macros.html) (read 2026-09-27)
- Bruin: [`bruin.get_url_parameter(field, parameter)`](https://getbruin.com/docs/bruin/assets/templating/macros.html) (read 2026-09-27)
- Bruin: [`bruin.get_url_path(field)`](https://getbruin.com/docs/bruin/assets/templating/macros.html) (read 2026-09-27)
- dbt-utils: [`get_url_host`](https://raw.githubusercontent.com/dbt-labs/dbt-utils/main/README.md) (read 2026-09-27)
- dbt-utils: [`get_url_parameter`](https://raw.githubusercontent.com/dbt-labs/dbt-utils/main/README.md) (read 2026-09-27)
- dbt-utils: [`get_url_path`](https://raw.githubusercontent.com/dbt-labs/dbt-utils/main/README.md) (read 2026-09-27)
- Duckle: [`URL Parse`](https://github.com/slothflowlabs/duckle/blob/f85f8960edfb6efbf4cb89d58a7b32e16df0e867/website/docs/components.html) (read 2026-09-25)
- EasyMorph: [`Parse web form submission`](https://help.easymorph.com/doku.php?id=transformations:parseformsubmission) (read 2026-09-27)
- Ibis: [`ExtractAuthority`](https://github.com/ibis-project/ibis/blob/05d2b293344e86cb41c1a426071734f7e270335a/ibis/expr/operations/strings.py) (read 2026-09-27)
- Ibis: [`ExtractFile`](https://github.com/ibis-project/ibis/blob/05d2b293344e86cb41c1a426071734f7e270335a/ibis/expr/operations/strings.py) (read 2026-09-27)
- Ibis: [`ExtractFragment`](https://github.com/ibis-project/ibis/blob/05d2b293344e86cb41c1a426071734f7e270335a/ibis/expr/operations/strings.py) (read 2026-09-27)
- Ibis: [`ExtractHost`](https://github.com/ibis-project/ibis/blob/05d2b293344e86cb41c1a426071734f7e270335a/ibis/expr/operations/strings.py) (read 2026-09-27)
- Ibis: [`ExtractPath`](https://github.com/ibis-project/ibis/blob/05d2b293344e86cb41c1a426071734f7e270335a/ibis/expr/operations/strings.py) (read 2026-09-27)
- Ibis: [`ExtractProtocol`](https://github.com/ibis-project/ibis/blob/05d2b293344e86cb41c1a426071734f7e270335a/ibis/expr/operations/strings.py) (read 2026-09-27)
- Ibis: [`ExtractQuery`](https://github.com/ibis-project/ibis/blob/05d2b293344e86cb41c1a426071734f7e270335a/ibis/expr/operations/strings.py) (read 2026-09-27)
- Ibis: [`ExtractUserInfo`](https://github.com/ibis-project/ibis/blob/05d2b293344e86cb41c1a426071734f7e270335a/ibis/expr/operations/strings.py) (read 2026-09-27)
- OpenRefine: [`URI parsing`](https://openrefine.org/docs/manual/grelfunctions#uri-parsing) (read 2026-09-27)
- Power Query M: [`Uri functions`](https://learn.microsoft.com/en-us/powerquery-m/uri-functions) (read 2026-09-27)
- RapidMiner Studio: [`Decode URLs`](https://docs.rapidminer.com/latest/studio/operators/extensions/Web%20Mining/utility/decode_urls.html) (read 2026-09-27)
- RapidMiner Studio: [`Encode URLs`](https://docs.rapidminer.com/latest/studio/operators/extensions/Web%20Mining/utility/encode_urls.html) (read 2026-09-27)
- Trifacta: [`Extract query strings`](https://help.alteryx.com/aac/en/trifacta-classic/reference/transformation-reference.html) (read 2026-09-27)
