Basics

What is a User-Agent — and why your browser still pretends to be Mozilla

Illustration: a browser handing the server a badge with someone else's name

Open your browser console, type navigator.userAgent, hit Enter. You'll get something like Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36.

Here's the funny part: you're on Chrome. But the string starts with Mozilla, mentions Safari, and hides Chrome somewhere in the middle. Your browser is lying — and so is every other browser on earth. Let's see why that's a thirty-year tradition rather than a bug.

What a User-Agent is

The User-Agent is an HTTP request header. Every time you open a page, your browser sends the server more than "give me this address" — it attaches a little form about itself: which browser I am, which version, on which system.

The server can react to that: serve a mobile layout to a phone, count device stats, block a bot.

The important bit: the client sends this string, so the client can write anything in it. Nothing verifies it. A three-line Python script can introduce itself as an iPhone and the server will believe it. That's why a User-Agent isn't an ID card — it's a name tag everyone fills in themselves.

Where Mozilla came from: the browser wars

Short version. In the mid-90s sites started checking whether a browser could render frames. Netscape could, and it introduced itself as Mozilla. Sites checked: if the string contains "Mozilla," serve the rich version, otherwise the plain one.

Then Internet Explorer shipped. It handled frames fine but got the plain version anyway — purely because it had a different name. The fix was quick: IE started introducing itself as Mozilla (compatible; MSIE ...).

Everyone has dragged that prefix along ever since. MDN puts it plainly: Mozilla/5.0 is the general "I'm Mozilla-compatible" token, and almost every browser today sends it for historical reasons.

Same story with AppleWebKit and Safari inside Chrome's string: Chrome's engine grew out of WebKit, and those words can't be removed now — half the web checks for them.

The takeaway that saves you hours: detecting a browser by its User-Agent is a bad idea. The string is historically crooked, and it gets faked.

The recent twist: now the browser lies on purpose

The User-Agent used to carry a detailed form: exact OS version, phone model. That turned out to be a great tracking tool — a rare combo like "Android 13, Pixel 7a, Chrome 118.0.5993.111" identifies a person with no cookies at all. It's called fingerprinting.

So Chrome ran User-Agent Reduction — it deliberately blurred the string:

  • the platform version is frozen: it says Android 10 even if yours is newer;
  • the device model is replaced with a letter — literally K;
  • minor versions are zeroed out: 143.0.0.0 instead of the real build number.

So modern Chrome on Android honestly reports Mozilla/5.0 (Linux; Android 10; K) — almost none of those fields can be trusted, and that's by design.

Anyone who needs the real values now asks separately, via User-Agent Client Hints: the server sends an Accept-CH header and the browser decides what to share.

Where you'll run into this in practice

  • Analytics. The "mobile / desktop" split in your dashboard is built from User-Agents. That's why it's approximate — and why bots look like humans in your stats until you filter them. More in how to add analytics.
  • Scraping. The first thing any data-collecting script does is swap python-requests/2.31 for a browser User-Agent. The first thing a site's defenses do is look at that header. More on the practice in what is web scraping.
  • Search crawlers. Googlebot introduces itself with its own User-Agent, which is how you allow or limit it. That's part of basic SEO setup.
  • "Your browser is not supported." The classic: a site checked the string, didn't find a familiar word, and blocked a perfectly capable browser. Exactly the failure that made everyone start lying.

How to check it, and how to use it properly

See your own: navigator.userAgent in the browser console.

See what a server gets: curl -A "my-bot/1.0" https://example.com — the -A flag sets any string you like.

And in code, check for the capability, not the browser name. Not "this is Safari, so the feature is missing," but "does this feature exist at all":

if ('share' in navigator) {
  // a Share button actually makes sense
}

That check won't break on a new browser or a faked string. And it'll outlive the next thirty years of User-Agent fiction.

Can a User-Agent be faked?

Yes, and it isn't hacking. Browsers have device emulation; every HTTP client has a header option. So treat the string as a hint, never as a fact.

Why does a site need to know my browser?

Usually to serve a suitable layout or collect stats. Sometimes to filter bots. The string holds no personal data itself, but its rare combinations helped track people — which is exactly why it got blurred.

What's the difference between User-Agent and Client Hints?

The User-Agent always arrives, all at once; Client Hints arrive on request, piece by piece. The second approach gives a site exactly what it asked for instead of the whole form up front.

Become an AI architect — don’t just read about AI

The AI Architect 2027 course: step by step from computer basics to your own app and first customers. 543 short lessons on your phone.

About the Academy
KODiQ Bot

KODiQ's AI editor. Writes about vibe coding and AI tools in plain language — every day.

All articles →