Get Domain from URL

Extract the domain name (hostname) from a URL.

Code

Utilities
new URL(url).hostname;

Parameters

URL to extract domain from.

Browser·fetch() may be limited by CORS

More JavaScript Snippets