coderef

URLBaseline · Widely available

A URL object represents a web address, like https://example.com/, and parts of the address, such as the domain, path, and query string (as URLSearchParams).

Supported in all major browsers for at least 30 months — safe to use without fallbacks. Baseline since Jul 29, 2015. Widely available since Jan 29, 2018.

Browser support

DesktopChrome
1–31Not supported
32+Supportedsince Jan 14, 2014
Current: 155
Edge
12+Supportedsince Jul 29, 2015
Current: 154
Firefox
1–18Not supported
19+Supportedsince Feb 19, 2013
Current: 157
Safari
1–6Not supported
7+Supportedsince Oct 22, 2013
Current: 27
MobileChrome Android
18–31Not supported
32+Supportedsince Jan 15, 2014
Current: 155
Firefox Android
4–18Not supported
19+Supportedsince Feb 19, 2013
Current: 157
Safari iOS
1–6Not supported
7+Supportedsince Sep 18, 2013
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: URL.

Feature detection

JS · check before using
if ("URL" in globalThis) {
  // URL is available
} else {
  // load a polyfill or use a fallback
}

Sub-features

Support for each part of the feature (38). The overall table above shows when the whole feature works.

Sub-featureChromeEdgeFirefoxSafariChrome AndroidFirefox AndroidSafari iOS
URL321219732197
URL.URL32122614.1322614.5
URL.hash321322732227
URL.host321322732227
URL.hostname32132210322210
URL.href32132210322210
URL.origin32122610322610
URL.parse_static1261261261812612618
URL.password32122610322610
URL.pathname32132210322210
URL.port32132210322210
URL.protocol32132210322210
URL.search32132210322210
URL.searchParams51172910.1512910.3
URL.toJSON71175411715411
URL.toString321754732547
URL.username32122610322610
URLSearchParams49172910.1492910.3
URLSearchParams.@@iterator49174410.1494410.3
URLSearchParams.URLSearchParams49172910.1492910.3
Show 18 more
Sub-featureChromeEdgeFirefoxSafariChrome AndroidFirefox AndroidSafari iOS
URLSearchParams.URLSearchParams.USVString49172910.1492910.3
URLSearchParams.URLSearchParams.record61175411615411
URLSearchParams.URLSearchParams.sequence58175311585311
URLSearchParams.append49172910.1492910.3
URLSearchParams.delete49172914492914
URLSearchParams.delete.value_parameter1171171151711711517
URLSearchParams.entries49174410.1494410.3
URLSearchParams.forEach49174410.1494410.3
URLSearchParams.get49172910.1492910.3
URLSearchParams.getAll49172910.1492910.3
URLSearchParams.has49172910.1492910.3
URLSearchParams.has.value_parameter1171171151711711517
URLSearchParams.keys49174410.1494410.3
URLSearchParams.set49172910.1492910.3
URLSearchParams.size1131131121711311217
URLSearchParams.sort61175411615411
URLSearchParams.toString49172910.1492910.3
URLSearchParams.values49174410.1494410.3