Visit homepage

URL character limit

  • Planted:

I was curious how much state I could actually store in a serverless, shareable way for a tiny weekend project I’m thinking about. The TL;DR is that you should keep URLs under 2000 characters to be safe, or 8000 if you don’t care about search engines.

Internet Explorer used to be the limiting factor because it only supported 2083 chars, but modern browsers can handle up to ~8000 bytes. From HTTP RFC 9110, section 4.1 (2022):

It is RECOMMENDED that all senders and recipients support, at a minimum, URIs with lengths of 8000 octets in protocol elements. Note that this implies some structures and on-wire representations (for example, the request line in HTTP/1.1) will necessarily be larger in some cases.

URLs use percent-encoding, so it’s not quite 1 byte per character, e.g. an underscore _ would be percent-encoded as %5F, requiring 3 bytes. You can even include emojis in URLs, although that may not be the best idea—especially in a domain name.

For search engine compatibility, the sitemaps protocol defines a 2048-character URL limit. CDNs also may have limits, and there’s even a status code for exceeding the limit: HTTP 414 URI Too Long.

I mainly sourced this from a really good answer from Paul Dixon on Stack Overflow that he’s been updating for over 14 years now.

Backlinks