What is the maximum length of a URL in different browsers?

asked15 years ago
last updated1 year ago
viewed1.6m times
Up Vote5.6kDown Vote

23 Answers

Up Vote9Down Vote
Grade: A

The maximum length of a URL (Uniform Resource Locator) can vary depending on the web browser being used. Here's a breakdown of the maximum URL lengths for some popular browsers:

  1. Microsoft Internet Explorer:

    • Maximum URL length: 2,083 characters
    • Maximum path length: 2,048 characters
  2. Google Chrome:

    • Maximum URL length: 32,779 characters
    • However, Chrome may have issues displaying URLs longer than 2,000 characters in the address bar.
  3. Mozilla Firefox:

    • Maximum URL length: Varies based on the operating system
      • Windows: 65,536 characters
      • macOS: 80,000 characters
    • Older versions of Firefox (before version 65) had a maximum URL length of 65,536 characters.
  4. Apple Safari:

    • Maximum URL length: 80,000 characters
  5. Opera:

    • Maximum URL length: 190,000 characters

It's important to note that while browsers may support long URLs, web servers and server-side frameworks often have their own limitations on URL lengths. For example:

  • Apache HTTP Server has a default maximum URL length of 8,190 characters.
  • Microsoft Internet Information Services (IIS) has a maximum URL length of 16,384 characters by default.

Additionally, the HTTP specification (RFC 2616) doesn't specify a maximum length for URLs. However, it recommends being cautious with URLs longer than 255 characters, as some older client or proxy implementations may not handle them properly.

In general, it's a good practice to keep URLs as concise and meaningful as possible. Long URLs can be difficult to read, share, and may cause issues with certain browsers or web servers. If you need to pass a large amount of data through URLs, consider using alternative methods such as POST requests or URL shortening techniques.

Here's an example of how you can check the maximum URL length supported by a browser using JavaScript:

function getMaxURLLength() {
  var maxLength = 0;
  
  try {
    var url = new URL('http://example.com');
    while (true) {
      url.searchParams.append('param', 'value');
      maxLength = url.href.length;
    }
  } catch (e) {
    // Reached the maximum URL length
    return maxLength;
  }
}

console.log('Maximum URL length:', getMaxURLLength());

This code creates a URL object and keeps appending query parameters until an exception is thrown, indicating that the maximum URL length has been reached. The maxLength variable stores the length of the last valid URL before the exception occurred.

Up Vote9Down Vote
Grade: A

The maximum length of a URL that can be handled by a web browser is not a fixed value, as it can depend on the specific implementation of the browser and the operating system it's running on. However, I can provide you with some general information:

  1. Google Chrome: The maximum length for a single URL in Chrome is 2097152 characters (2 MB). However, most web servers have limits on the size of data that can be returned in a single response, and very large URLs might not be supported by some servers or websites.

  2. Mozilla Firefox: Mozilla Firefox does not officially state a specific limit for the maximum length of a URL. In practice, you may encounter issues when attempting to load URLs longer than 65535 characters due to limitations in the way data is transmitted over the internet using TCP/IP.

  3. Apple Safari: Safari has a stated limit of around 2 MB for a single URL (approximately 4097152 characters). However, this is a theoretical limit and may vary based on different factors.

  4. Microsoft Edge: The maximum length for a single URL in Microsoft Edge is 2097152 characters (2MB).

It's important to remember that long URLs can have negative impacts such as longer load times, increased risk of errors, and issues with server capacity or network reliability. Best practice would be to keep your URLs as short and simple as possible while still meeting your needs.

Up Vote9Down Vote
Grade: A

Short answer - de facto limit of 2000 characters

If you keep URLs under 2000 characters, they'll work in virtually any combination of client and server software. If you are targeting particular browsers, see below for more details on specific limits.

Longer answer - first, the standards...

RFC 2616 (Hypertext Transfer Protocol HTTP/1.1) section 3.2.1 says

The HTTP protocol does not place any a priori limit on the length of a URI. Servers MUST be able to handle the URI of any resource they serve, and SHOULD be able to handle URIs of unbounded length if they provide GET-based forms that could generate such URIs. A server SHOULD return 414 (Request-URI Too Long) status if a URI is longer than the server can handle (see section 10.4.15). That RFC has been obsoleted by RFC7230 which is a refresh of the HTTP/1.1 specification. It contains similar language, but also goes on to suggest this: Various ad hoc limitations on request-line length are found in practice. It is RECOMMENDED that all HTTP senders and recipients support, at a minimum, request-line lengths of 8000 octets.

...and the reality

That's what the say. For the , there was an article on boutell.com (link goes to Internet Archive backup) that discussed what individual browser and server implementations will support. The executive summary is:

Extremely long URLs are usually a mistake. Don't use them if you intend your site to work for the majority of Internet users. (Note: this is a quote from an article written in , but in 2015 IE's declining usage means that longer URLs work for the majority. However, IE still has the limitation...)

Internet Explorer's limitations...

IE8's maximum URL length is 2083 chars, and it seems IE9 has a similar limit. I've tested IE10 and the address bar will only accept 2083 chars. You can a URL which is longer than this, but the address bar will still only show 2083 characters of this link. There's a nice writeup on the IE Internals blog which goes into some of the background to this. There are mixed reports IE11 supports longer URLs - see comments below. Given some people report issues, the general advice still stands.

Search engines like URLs < 2048 chars...

Be aware that the sitemaps protocol, which allows a site to inform search engines about available pages, has a limit of 2048 characters in a URL. If you intend to use sitemaps, a limit has been decided for you! (see Calin-Andrei Burloiu's answer below) There's also some research from 2010 into the maximum URL length that search engines will crawl and index. They found the limit was 2047 chars, which appears allied to the sitemap protocol spec. However, they also found the Google SERP tool wouldn't cope with URLs longer than 1855 chars.

CDNs have limits

CDNs also impose limits on URI length, and will return a 414 Too long request when these limits are reached, for example:

Additional browser roundup

I tested the following against an Apache 2.4 server configured with a very large LimitRequestLine and LimitRequestFieldSize.

Browser     Address bar   document.location
                          or anchor tag
------------------------------------------
Chrome          32779           >64k
Android          8192           >64k
Firefox          >64k           >64k
Safari           >64k           >64k
IE11             2047           5120
Edge 16          2047          10240

See also this answer from Matas Vaitkevicius below.

Is this information up to date?

This is a popular question, and as the original research is ~14 years old I'll try to keep it up to date: As of , the advice still stands. Even though IE11 may possibly accept longer URLs, the ubiquity of older IE installations plus the search engine limitations mean staying under 2000 chars is the best general policy.

Up Vote8Down Vote
Grade: B

Short answer - de facto limit of 2000 characters

If you keep URLs under 2000 characters, they'll work in virtually any combination of client and server software. If you are targeting particular browsers, see below for more details on specific limits.

Longer answer - first, the standards...

RFC 2616 (Hypertext Transfer Protocol HTTP/1.1) section 3.2.1 says

The HTTP protocol does not place any a priori limit on the length of a URI. Servers MUST be able to handle the URI of any resource they serve, and SHOULD be able to handle URIs of unbounded length if they provide GET-based forms that could generate such URIs. A server SHOULD return 414 (Request-URI Too Long) status if a URI is longer than the server can handle (see section 10.4.15). That RFC has been obsoleted by RFC7230 which is a refresh of the HTTP/1.1 specification. It contains similar language, but also goes on to suggest this: Various ad hoc limitations on request-line length are found in practice. It is RECOMMENDED that all HTTP senders and recipients support, at a minimum, request-line lengths of 8000 octets.

...and the reality

That's what the say. For the , there was an article on boutell.com (link goes to Internet Archive backup) that discussed what individual browser and server implementations will support. The executive summary is:

Extremely long URLs are usually a mistake. Don't use them if you intend your site to work for the majority of Internet users. (Note: this is a quote from an article written in , but in 2015 IE's declining usage means that longer URLs work for the majority. However, IE still has the limitation...)

Internet Explorer's limitations...

IE8's maximum URL length is 2083 chars, and it seems IE9 has a similar limit. I've tested IE10 and the address bar will only accept 2083 chars. You can a URL which is longer than this, but the address bar will still only show 2083 characters of this link. There's a nice writeup on the IE Internals blog which goes into some of the background to this. There are mixed reports IE11 supports longer URLs - see comments below. Given some people report issues, the general advice still stands.

Search engines like URLs < 2048 chars...

Be aware that the sitemaps protocol, which allows a site to inform search engines about available pages, has a limit of 2048 characters in a URL. If you intend to use sitemaps, a limit has been decided for you! (see Calin-Andrei Burloiu's answer below) There's also some research from 2010 into the maximum URL length that search engines will crawl and index. They found the limit was 2047 chars, which appears allied to the sitemap protocol spec. However, they also found the Google SERP tool wouldn't cope with URLs longer than 1855 chars.

CDNs have limits

CDNs also impose limits on URI length, and will return a 414 Too long request when these limits are reached, for example:

Additional browser roundup

I tested the following against an Apache 2.4 server configured with a very large LimitRequestLine and LimitRequestFieldSize.

Browser     Address bar   document.location
                          or anchor tag
------------------------------------------
Chrome          32779           >64k
Android          8192           >64k
Firefox          >64k           >64k
Safari           >64k           >64k
IE11             2047           5120
Edge 16          2047          10240

See also this answer from Matas Vaitkevicius below.

Is this information up to date?

This is a popular question, and as the original research is ~14 years old I'll try to keep it up to date: As of , the advice still stands. Even though IE11 may possibly accept longer URLs, the ubiquity of older IE installations plus the search engine limitations mean staying under 2000 chars is the best general policy.

Up Vote8Down Vote
Grade: B

The maximum length of a URL (Uniform Resource Locator) can vary across different web browsers. Here's a breakdown of the maximum URL length in some popular browsers:

  1. Google Chrome:

    • Chrome has a maximum URL length of 2,083 characters (including the protocol, domain, path, and query parameters).
  2. Mozilla Firefox:

    • Firefox has a maximum URL length of 65,536 characters.
  3. Microsoft Edge:

    • Microsoft Edge, which is based on the Chromium engine, also has a maximum URL length of 2,083 characters.
  4. Safari:

    • Safari has a maximum URL length of 2,083 characters.
  5. Opera:

    • Opera, which is also based on the Chromium engine, has a maximum URL length of 2,083 characters.
  6. Internet Explorer:

    • Internet Explorer has a maximum URL length of 2,083 characters.

It's important to note that these limits are not set in stone and may change over time as browser technologies evolve. Additionally, the maximum URL length can also depend on the server-side configuration and the underlying web server software being used.

Here's a code example to demonstrate the maximum URL length in JavaScript:

// Function to check the length of a URL
function checkURLLength(url) {
  if (url.length > 2083) {
    console.log("URL length exceeds the maximum limit in most browsers.");
  } else {
    console.log("URL length is within the maximum limit.");
  }
}

// Example usage
const longURL = "https://example.com/this-is-a-very-long-url-that-exceeds-the-maximum-length-in-most-browsers?param1=value1&param2=value2&param3=value3&param4=value4&param5=value5&param6=value6&param7=value7&param8=value8&param9=value9&param10=value10";
const shortURL = "https://example.com/short-url";

checkURLLength(longURL); // Output: URL length exceeds the maximum limit in most browsers.
checkURLLength(shortURL); // Output: URL length is within the maximum limit.

In summary, it's generally recommended to keep URLs as short as possible, especially if the URL needs to be shared or used in various contexts, to ensure compatibility across different web browsers.

Up Vote8Down Vote
Grade: B

The maximum length of a URL (Uniform Resource Locator) can vary depending on the web browser and the operating system. However, there are some general guidelines and limitations to keep in mind:

  1. Internet Explorer (IE): In Internet Explorer, the maximum length of a URL is approximately 2,083 characters. This limit includes the entire URL, including the protocol (e.g., http://), domain name, path, query string, and fragment identifier.

  2. Mozilla Firefox: Firefox has a maximum URL length of around 65,536 characters. However, it's important to note that some web servers and proxy servers may impose additional limitations.

  3. Google Chrome: Chrome does not have a hard-coded limit on the maximum URL length. However, it follows the guidelines set by the operating system and web servers. On most systems, the maximum URL length is typically around 2,000-8,000 characters.

  4. Safari: Safari, the default web browser for macOS and iOS, has a maximum URL length of approximately 80,000 characters.

  5. Opera: Opera has a maximum URL length of around 190,000 characters.

It's worth noting that while these are the theoretical maximum URL lengths, it's generally recommended to keep URLs as short and concise as possible for better usability, readability, and compatibility with various web servers and proxies.

Additionally, some web servers and proxies may have their own limitations on the maximum URL length they can handle. For example, Apache web servers typically have a default limit of around 8,000 characters for the entire URL.

If you need to work with longer URLs, you can consider using URL shortening services or techniques like URL encoding or URL rewriting to keep the visible URL shorter while still allowing for longer URLs behind the scenes.

Here's an example of how you can check the length of a URL in JavaScript:

const url = 'https://example.com/very/long/path/with/query/string?param1=value1&param2=value2';
const urlLength = url.length;
console.log(`The length of the URL is ${urlLength} characters.`);

This code will output the length of the provided URL in characters, allowing you to ensure that it doesn't exceed the maximum length supported by the target browser or web server.

Up Vote8Down Vote
Grade: B

In general, the maximum length of an URL can vary depending on the browser and its configuration. However, some browsers have stricter limitations than others. Here are some commonly encountered limits:

  • Internet Explorer: The maximum URL length is 2,083 characters.
  • Firefox: There is no fixed limit for URLs in Firefox, but long URLs may cause performance issues or errors.
  • Chrome: Chrome has no built-in limit for URLs, but extremely long URLs may cause performance issues or errors.
  • Safari: The maximum URL length for Safari is 2048 characters.
  • Opera: The maximum URL length for Opera is 65,536 bytes (approximately 167,772 characters).
  • Edge: Edge has no built-in limit for URLs, but extremely long URLs may cause performance issues or errors.

It's important to note that these limits may vary depending on the browser version and other factors. Additionally, some websites may have their own length restrictions for URLs, so it's always best to check the website's documentation or contact the site owner if you encounter any issues with URL lengths.

Up Vote8Down Vote
Grade: B

The maximum length of a URL varies across different browsers due to differences in their handling of Uniform Resource Locators (URLs). Here are the maximum URL lengths for some common browsers:

  • Google Chrome: 2,083 characters.
  • Mozilla Firefox: 64,519 characters.
  • Apple Safari: 81,899 characters.
  • Microsoft Edge: 2,048 characters.
  • Internet Explorer 11: 2,083 characters.
Up Vote8Down Vote
Grade: B

Here's the maximum length of a URL for some popular browsers:

  • Chrome: 64KB or 2083 characters (including all headers)
  • Firefox: 65,536 bytes or ~61,000 characters
  • Safari: 64KB or 2048 characters
  • Edge: 32,768 bytes or ~31,000 characters
  • Opera: 64KB or 2083 characters
  • Internet Explorer: 2083 characters
Up Vote8Down Vote
Grade: B

There is no hard and fast rule to the maximum length of a URL, as it largely depends on various factors like server limit, browser limitations etc. However, typical web servers have an upper limit of 2000 characters per URI (Universal Resource Identifier). But some browsers do restrict the total size of all components in a URL up to around 2000 characters. Other browsers might handle larger URLs more gracefully if they are correctly coded and adhere to the standards set for URIs. Please refer to documentation or specifications from relevant browser vendors regarding their limits.

Up Vote8Down Vote
Grade: B

The maximum length of a URL in different browsers is:

  • Chrome: 255 characters (including the protocol, hostname, and path)
  • Safari: 253 characters (including the protocol, hostname, and path)
  • Firefox: 253 characters (including the protocol, hostname, and path)
  • Edge: 255 characters (including the protocol, hostname, and path)
  • Opera: 256 characters (including the protocol, hostname, and path)

Note:

  • The maximum length of a URL can be different for different platforms, such as mobile browsers and web servers.
  • URLs exceeding the maximum length may be truncated or returned as an error.
  • URL shorteners can be used to reduce the length of a URL, but they cannot change the maximum length.
Up Vote8Down Vote
Grade: B

Maximum URL Length in Different Browsers:

Google Chrome:

  • Maximum length: 65,533 characters
  • Note: Chrome automatically truncates URLs beyond this limit, displaying an error message.

Mozilla Firefox:

  • Maximum length: 64,000 characters
  • Note: Firefox also truncates URLs beyond this limit.

Microsoft Edge:

  • Maximum length: 4,096 characters
  • Note: Edge has a lower limit than Chrome and Firefox.

Apple Safari:

  • Maximum length: 208,352 characters
  • Note: Safari has a significantly higher limit than other browsers.

Other Browsers:

  • The maximum URL length may vary slightly between different browsers. It's always best to check the specific documentation for your target browser.

Additional Notes:

  • The actual usable length of a URL is less than the maximum limit due to the presence of query parameters and other components.
  • In practice, URLs should be kept as short as possible for better readability and accessibility.
  • Some websites may have their own internal limitations on URL length, even within the browser's limits.
  • If you need to use URLs longer than the maximum length, you can use a URL shortener service.

Example:

The maximum length of a URL in Google Chrome is 65,533 characters. For example, the following URL is valid in Chrome:

abc...xyz123.com/very-long-url?query-params=1234


However, the following URL is too long for Chrome:

abc...xyz123.com/very-long-url?query-params=1234567890 ```

Up Vote8Down Vote
Grade: B

The maximum length of a URL in different browsers varies, but generally, it's around 2,000 characters. Here are the maximum URL lengths for some popular browsers:

  • Chrome: 2,083 characters
  • Firefox: 65,536 characters
  • Internet Explorer: 2,083 characters
  • Microsoft Edge: 2,083 characters

Keep in mind that the length can also be affected by the server and any proxy servers in between.

Up Vote8Down Vote
Grade: B

The maximum URL length varies slightly between different web browsers. Here's a general guideline for the popular ones:

  • Internet Explorer: Maximum URL length is 2048 characters.
  • Firefox: Maximum URL length is technically unlimited, but they advise keeping it under 65536 characters.
  • Google Chrome: Maximum URL length is 32779 characters.
  • Safari: Maximum URL length is around 80000 characters.
  • Microsoft Edge: Similar to Internet Explorer, supports up to 2048 characters.

For optimal compatibility across different platforms and browsers, it's generally recommended to keep URLs under 2000 characters. This ensures that they will work well within the limits of most browsers and web servers (like Apache and IIS, which have their own limits).

Up Vote8Down Vote
Grade: B

Here is the maximum length of a URL in different browsers:

  • Internet Explorer: 2,048 characters
  • Firefox: 65,536 characters (limited by the operating system)
  • Google Chrome: 2,048 characters (limited by the operating system)
  • Safari: 80,000 characters
  • Opera: 190,000 characters
  • Microsoft Edge: 2,048 characters

Note: These limits may vary depending on the version of the browser and the operating system being used.

Up Vote8Down Vote
Grade: B

The maximum length of a URL is not strictly defined and can vary between different browsers, web servers, and operating systems. However, there is a recommended limit of 2,048 characters for a URL defined by RFC 3986, which is the current standard for URLs.

Here are some maximum URL length limits for popular browsers:

  • Google Chrome: 2MB (around 2,000,000 characters)
  • Mozilla Firefox: 100,000 characters (approx.)
  • Microsoft Edge: 2MB (around 2,000,000 characters)
  • Safari: 80,000 characters (approx.)

It's worth noting that while these limits exist, it's generally a good practice to keep URLs as short and descriptive as possible. Long URLs can be difficult to read, share, and can potentially cause issues with some web servers and applications.

Therefore, if you encounter a situation where you need to generate long URLs, consider using URL shortening services or techniques like URL fragment identifiers or query parameter encoding to keep the URL length within reasonable limits.

For example, you can encode URL parameters using Base64 encoding to reduce their length. Here's an example in Python:

import base64

# Define a long string to be encoded as a URL parameter
long_string = 'a' * 100000

# Encode the long string using Base64
encoded_string = base64.b64encode(long_string.encode()).decode()

# Construct the URL with the encoded parameter
url = f'https://example.com/?param={encoded_string}'

print(url)

This will generate a URL that looks like this:

https://example.com/?param=EABoaHJpcyBpbiBmYXIgZ2VuZXJhdGlvbiBmYXIuCkZyb20gaGVyZSwKCk1lbW9yeS5SU1Jvb2tscyAtLSBQYXVsIFIuIEZyb20gUi5TdHJpbmcgSXJ1bmsgQVhOaWdofQ==

As you can see, the encoded parameter is much shorter than the original long string, and the overall URL length is within reasonable limits.

Up Vote8Down Vote
Grade: B
  1. Google Chrome: Up to 2000 characters

  2. Mozilla Firefox: Up to 32,767 characters

  3. Safari: Up to 2083 characters

  4. Microsoft Edge: Up to 2083 characters

  5. Internet Explorer: Up to 2083 characters

Note: Always consider the URL's structure and content when determining its maximum length, as some browsers may have limitations on certain types of URLs.

Up Vote8Down Vote
Grade: B

The maximum length of a URL that different browsers can handle varies, and it's not just a browser-specific limitation but also depends on the server and protocols involved. However, here are some general limits for popular web browsers:

  • Internet Explorer: The maximum URL length is 2,083 characters. This limit is based on the IE's address bar and the MAX_PATH limitation in the WinInet API.

  • Microsoft Edge: The limit is similar to Internet Explorer, with a maximum of around 2,083 characters, as it also relies on the WinInet API.

  • Mozilla Firefox: There is no specific limit documented by Mozilla, but practical tests suggest it can handle URLs longer than 100,000 characters.

  • Google Chrome: Similar to Firefox, Chrome does not have a well-documented limit and can handle very long URLs, often exceeding 100,000 characters.

  • Safari: The limit is not well-documented, but it is known to handle URLs longer than the IE limit, with some sources suggesting it can handle URLs up to 80,000 characters or more.

  • Opera: Opera, which now uses the Blink engine (same as Chrome), also does not have a strict limit and can handle very long URLs.

It's important to note that even if a browser can handle long URLs, other parts of the web infrastructure might not. For example, the HTTP protocol does not define a limit for URL length, but servers like Apache or IIS might have their own limitations. The get request line length is limited to 8190 bytes in Apache, and IIS has a default limit of 16KB for the URL length.

For web development purposes, it is recommended to keep URLs as short as possible and to use query parameters efficiently to avoid hitting these limits. If a long URL is necessary, consider using POST requests instead of GET requests to send data to the server.

Remember that extremely long URLs can cause issues not only with browsers but also with intermediate proxies or other internet infrastructure components, and they can negatively impact the performance and usability of web applications.

Up Vote7Down Vote
Grade: B
  • Chrome: 2 MB
  • Firefox: No Limit (practically limited by system memory)
  • Safari: Approximately 2 GB
  • Edge: Approximately 2 MB
Up Vote7Down Vote
Grade: B
Browser Maximum URL Length
Chrome 2083 characters
Firefox 65,536 characters
Safari 2048 characters
Edge 2083 characters
Internet Explorer 11 2083 characters
Up Vote6Down Vote
Grade: B

The maximum length of a URL depends on the browser and operating system. However, the general consensus is to keep URLs under 2048 characters.

Up Vote6Down Vote
Grade: B
  • Firefox: 208,003 characters
  • Google Chrome: 65,535 bytes (approximately 20,000 characters)
  • Internet Explorer: 2,083 characters
  • Safari: 65,535 bytes (approximately 20,000 characters)
Up Vote6Down Vote
Grade: B

The maximum length of a URL in different browsers can vary widely due to different browser implementations and limitations. In general, modern browsers have sufficient processing power to handle even long URLs without significant performance impact. That being said, it is always good practice to test the behavior of your website and application across a range of devices and browsers.