What Is the Character Limit on Url

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

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 standards say. For the reality, 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. URLs over 2,000 characters
will not work in the most popular web
browsers.
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 2006, but in 2015 IE's declining usage means that longer URLs do 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 click 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:

  • Fastly 8Kb
  • CloudFront 8Kb
  • CloudFlare 16Kb

(credit to timrs2998 for providing that info in the comments)

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 Jan 2021, 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.

What is the character limit on URL

According to Microsoft it's 2048. Since they invented the internet (and also the light, the darkness and Linux) they are right. :-) .... or.. and since IE forces this lower value, it's the lowest common denominator.

http://support.microsoft.com/kb/208427

Under Firefox, I see people on the net reporting URLs of 0xFFFF working:
http://forums.mozillazine.org/viewtopic.php?f=38&t=155648&start=0&st=0&sk=t&sd=a

Here is another post which talks about this:
http://hiox.org/index.php?id=425


EDIT: this is very sad that almost 5 years after I wrote this answer - it is still true. If you can, look at the history of this answer.

EDIT2: I found a better answer on StackOverflow - What is the maximum length of a URL in different browsers?

EDIT3: 9 years after - Explorer is deprecated in favor of Edge, Edge soon to be re-designed using Blink (making it very close to Chrome). I wonder how relevant this answer is.

What is a safe maximum length a segment in a URL path should be?

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

In short

According to the HTTP spec, there is no limit to a URL's length. Keep your URLs under 2048 characters; this will ensure the URLs work in all clients & server configurations. Also, search engines like URLs to remain under approximately 2000 characters.

Chrome has a 2MB limit for URLs, IE8 and 9 have a 2084 character limit. So everything points in keeping your URLs limited to approx. 2000 characters.

Also, from a usability point-of-view, URLs that long are not usable/readable by users.

However, the domain name has a max. length of 255 characters.
So to be on the safe side, the max. length of an URL segment would be around 1745 characters, given that your URL exists out of 1 segment.

What is the maximum possible length of a query string?

RFC 2616 (Hypertext Transfer Protocol — HTTP/1.1) states there is no limit to the length of a query string (section 3.2.1). RFC 3986 (Uniform Resource Identifier — URI) also states there is no limit, but indicates the hostname is limited to 255 characters because of DNS limitations (section 2.3.3).

While the specifications do not specify any maximum length, practical limits are imposed by web browser and server software. Based on research which is unfortunately no longer available on its original site (it leads to a shady seeming loan site) but which can still be found at Internet Archive Of Boutell.com:

  • Microsoft Edge (Browser)

    The limit appears to be around 81578 characters. See URL Length limitation of Microsoft Edge

  • Chrome

    It stops displaying the URL after 64k characters, but can serve more than 100k characters. No further testing was done beyond that.

  • Firefox (Browser)

    After 65,536 characters, the location bar no longer displays the URL in Windows Firefox 1.5.x. However, longer URLs will work. No further testing was done after 100,000 characters.

  • Safari (Browser)

    At least 80,000 characters will work. Testing was not tried beyond that.

  • Opera (Browser)

    At least 190,000 characters will work. Stopped testing after 190,000 characters. Opera 9 for Windows continued to display a fully editable,
    copyable and pasteable URL in the location bar even at 190,000 characters.

  • Microsoft Internet Explorer (Browser)

    Microsoft states that the maximum length of a URL in Internet Explorer is 2,083 characters, with no more than 2,048 characters in the path portion of the URL. Attempts to use URLs longer than this produced a clear error message in Internet Explorer.

  • Apache (Server)

    Early attempts to measure the maximum URL length in web browsers bumped into a server URL length limit of approximately 4,000 characters, after which Apache produces a "413 Entity Too Large" error. The current up to date Apache build found in Red Hat Enterprise Linux 4 was used. The official Apache documentation only mentions an 8,192-byte limit on an individual field in a request.

  • Microsoft Internet Information Server (Server)

    The default limit is 16,384 characters (yes, Microsoft's web server accepts longer URLs than Microsoft's web browser). This is configurable.

  • Perl HTTP::Daemon (Server)

    Up to 8,000 bytes will work. Those constructing web application servers with Perl's HTTP::Daemon module will encounter a 16,384 byte limit on the combined size of all HTTP request headers. This does not include POST-method form data, file uploads, etc., but it does include the URL. In practice this resulted in a 413 error when a URL was significantly longer than 8,000 characters. This limitation can be easily removed. Look for all occurrences of 16x1024 in Daemon.pm and replace them with a larger value. Of course, this does increase your exposure to denial of service attacks.

Maximum length for url in chrome browser

I believe it's stayed the same:

I could not find any limits on Chrome and Safari. Both are based on WebKit and it seems to have similar limits as Firefox has.

Firefox stops displaying after 64k characters, but can serve more than
100k characters.

you can read more about it in this article.

Generally speaking there is no "limit" to a URL's length, but this answer states that you should keep your URL's under 2048 chars regardless to make sure it works in every client and server.

More information about all browsers here.

What is the optimum limit for URL length? 100, 200+

A Url is path + querystring, and the linked article only talks about limiting the path. Therefore, if you're using asp.net, don't exceed a path of 260 characters. Less than 260 will always work, and asp.net has no troubles with long querystrings.

http://somewhere.com/directory/filename.aspx?id=1234
^^^^^^^- querystring
^^^^^^^^^^^^^^^^^^^^^^^^ -------- path

Typically the issue is with the browser. Long ago I did tests and recall that many browsers support 4k url's, except for IE which limits it to 2083, so for all practical purposes, limit it to 2083. I don't know if IE7 and 8 have the limitation, but if you're going to broad compatibility, you need to go for the lowest common denominator.

What is the maximum length a URL can be to be opened in a J2ME browser?

Short answer: it depends, but probably long enough.

Long answer, following investigation on SonyEricsson J2ME emulator (WTK 2.2.4), a K610i, and Samsung U700V.


Empirically testing: from the emulator, the platformRequest() passes the URL straight to the desktop browser (Firefox in this case).

http://test.example.com/?q=2048xxxxxxxxxxxxxxxxxxxxxxxxxxxx... xxxxxxxxxxxxxxxxxx2048

Looking at the logs of a test server, we see we can pass through very long URLs from the emulator to the desktop to the server.

On a device (in this case, a SonyEricsson K610i, user agent: "SonyEricssonK610i/R1CB Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1") can handle at least a URL of at least 3072 characters (upper bound c.3800).

On a second device Samsung U700V, user agent: "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.0.7) Gecko/20060909 Firefox/1.5.0.7 MG(Novarra-Vision/7.3)", the lower bound for URL length was 2048, but upper bound was less than 3072. Note that this could be a problem with Novarra transcoder, which has been known to (at least) re-write user-agent strings.

Without the Novarra transcode (switching networks), the U700V has a user agent "SAMSUNG-SGH-U700-Vodafone/BUGK1 SHP/VPP/R5 NetFront/3.4 Qtv5.3 SMM-MMS/1.2.0 profile/MIDP-2.0 configuration/CLDC-1.1", and has a lower bound of 3072 chars.


This effectively ends my interest in the answer to this question, as this empirical testing invalidates my theory that an upper bound on URL length is causing my problem.

However, for completeness, I will include a potential cause of my problem:

The URL needed to connect has at least two query parameters. The ampersands separating the queries seem to confuse the emulator.

The emulator silently drops the second parameter.

On the Samsung, without a second parameter, the browser connects, but the long parameter is corrupted or missing.

On the K610i when a second parameter is used, the browser does not start properly.

is there any way to overcome the 2k character limitation on the URL length?

There's no realistic way to get around this - it's not a limitation in the specs or anything like that, but in IE itself and presumably how the URL is allocated (I believe the limit is actually 2083 characters by the way, for some reason).

Since IE needs the URL all in one go to send to the server, I can't think of any clever tricks that would enable you to work around it. Some options I considered were to send the query parameters via POST instead of GET (but this is often not interchangeable on the server side, and the clients will treat this differently in that the URL can't then appear in a hyperlink or be bookmarked or entered manually, and if the user wants to refresh they'll get the "send information again" warning, which makes sense since POST is meant to update information on the remote server, and it'll only work if it's the query string pushing it beyond the limit rather than some ungodly URL). Alternatively you could perhaps chunk up the URL, setting the overflow part in a cookie and then making the request to the stub of the URL, which is intelligent enough to pull the context out of the cookie and append it to the URL actually received. However this again complicates processing on the server, probably far too much to be used beyond a trivial application, and also still means you can't put that URL in hyperlinks or bookmarks or whatever, since an important part of it is client state.

Basically, everything else would involve rewriting the server to somehow piece together the extra information, and if you're able to do this then you should be able to simply change the URL scheme so that everything's below 2000 characters. So no - no real way around it.

(Though if you could use something like tinyurl to act as a proxy rather than issuing a browser redirect to the URL, that could work).



Related Topics



Leave a reply



Submit