coderef

URL.canParse()Baseline · Widely available

The URL.canParse() static method checks whether a URL can be parsed into a valid URL object. It's an alternative to calling new URL() in a try … catch statement.

Supported in all major browsers for at least 30 months — safe to use without fallbacks. Baseline since Dec 7, 2023. Widely available since Jun 7, 2026.

Browser support

DesktopChrome
1–119Not supported
120+Supportedsince Dec 5, 2023
Current: 155
Edge
12–119Not supported
120+Supportedsince Dec 7, 2023
Current: 154
Firefox
1–114Not supported
115+Supportedsince Jul 4, 2023
Current: 157
Safari
1–16.6Not supported
17+Supportedsince Sep 18, 2023
Current: 27
MobileChrome Android
18–119Not supported
120+Supportedsince Dec 5, 2023
Current: 155
Firefox Android
4–114Not supported
115+Supportedsince Jul 4, 2023
Current: 157
Safari iOS
1–16.6Not supported
17+Supportedsince Sep 18, 2023
Current: 27

How to use

This feature is Baseline widely available — use it freely, no fallback needed.

Example

Full syntax and examples are on MDN: canParse static.

Feature detection

JS · check before using
if ("URL" in globalThis && "canParse" in URL) {
  // URL.canParse is available
}