Use this formula to turn URLs such as https://www.example.com/articles/notion into a clean domain such as example.com.
if(
empty(prop("URL")),
"",
replaceAll(
replaceAll(
replaceAll(prop("URL"), "https?://", ""),
"^www\\.",
""
),
"[/?#].*",
""
)
)What this formula does
| Step | Result |
|---|---|
Remove http:// or https:// | www.example.com/articles |
Remove www. at the start | example.com/articles |
| Remove the path, query, or fragment | example.com |
The formula uses regular expressions in replaceAll(). It also returns a blank value when the URL property is empty.
Database setup
Create these properties in your Notion database:
| Property | Type | Example |
|---|---|---|
Name | Title | Notion Formula Guide |
URL | URL | https://www.example.com/guide?ref=notion |
Domain | Formula | The formula above |
If your URL property is named Website, replace prop("URL") with prop("Website").
Keep the www prefix
If you want www.example.com instead of example.com, remove the second replaceAll() call:
if(
empty(prop("URL")),
"",
replaceAll(
replaceAll(prop("URL"), "https?://", ""),
"[/?#].*",
""
)
)Extract the registered domain only
This formula keeps the last two domain parts for common domains:
replaceAll(prop("URL"), ".*?([a-z0-9-]+\\.[a-z]{2,})([/\\?#].*)?$", "$1")Use this variant carefully. Country-code domains such as example.co.uk and multi-level domains may need custom handling.
Common problems
If the path is still visible, check that the URL contains a slash, question mark, or hash after the domain and that the formula was pasted without changing the backslashes.
If www is still visible, make sure the URL starts with www.. The formula only removes that prefix at the beginning of the value.
This formula cleans the text; it does not validate whether the URL is reachable or correctly formatted.