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

14 Answers

Up Vote9Down Vote

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 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

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 (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

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

Sure, I'd be happy to help with that. The maximum length of a URL can vary depending on the browser and its settings. Here's some information on the maximum length allowed by popular browsers:

  • Chrome: 2560 characters (26-digit address) or 64,000 characters (with hyphens)
  • Firefox: 2000 characters for the path and up to 4000 characters in total
  • Internet Explorer: 1600 characters (30-digit address) or 80,000 characters in total

However, keep in mind that some browsers may allow you to create longer URLs by using techniques such as redirects. Additionally, certain protocols (e.g., FTP) may also be allowed to exceed the maximum URL length set by these browsers. As always, it's a good idea to test your URL before sharing it publicly or embedding it in a webpage to ensure it works correctly across different platforms and browsers.

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 Vote3Down Vote
Grade: C

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 Vote3Down Vote
Grade: C

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 Vote3Down Vote
Grade: C

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.

Up Vote2Down Vote
Grade: D

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 Vote2Down Vote
Grade: D

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 Vote2Down Vote
Grade: D

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.