WebmasterID logoWebmasterID
User agents

Mobile vs desktop UA detection

Distinguishing mobile from desktop clients is one of the few user-agent checks still broadly reliable: mobile browsers include a Mobile token and platform markers. But user-agent reduction trims finer detail, so for form-factor decisions the modern, robust approach is the Sec-CH-UA-Mobile Client Hint and responsive design rather than deep UA parsing.

Verified against primary sources

What this means

Mobile and desktop detection asks a simpler question than full device identification: what is the form factor? Mobile browser user agents conventionally include a Mobile token, alongside a platform marker such as an Android or iPhone/iOS indicator, which desktop user agents lack.

This coarse split is one of the more durable user-agent checks, because it survives the reduction that strips exact OS versions and device models. You can still tell phone-class from desktop-class clients fairly reliably.

Reliable signals and their limits

The presence of the Mobile token plus a mobile platform marker is a sound coarse signal. What is not reliable is fine-grained device or model detection: user-agent reduction removes much of that detail, and what remains is easy to spoof.

Tablets blur the line — some present mobile-like, some desktop-like user agents — so a strict two-way split can misclassify them. Treat form factor as a spectrum and avoid hard branching that assumes only phone-or-desktop.

The modern approach

For form-factor decisions, prefer the Sec-CH-UA-Mobile User-Agent Client Hint, a low-entropy boolean built for exactly this question, with the legacy Mobile token as a fallback. Better still, lean on responsive design and feature detection so layout adapts to viewport and capability rather than to a parsed device guess.

Keep any user-agent form-factor check coarse and resilient: degrade gracefully for clients you cannot classify, and never escalate from form-factor detection into device fingerprinting.

How it appears in analytics and logs

A user agent containing a Mobile token (and a mobile platform marker) indicates a mobile form factor; its absence on a known browser indicates desktop. This coarse split stays reliable even as UA reduction removes finer device detail.

Diagnostic use case

Detect form factor (mobile vs desktop) correctly for layout or routing decisions, using the Mobile token or Client Hints, while avoiding brittle device-model parsing.

What WebmasterID can help detect

WebmasterID derives coarse mobile/desktop context from the user agent (and Client Hints where present) for human-traffic breakdowns, while classifying bots out, so form-factor charts are not skewed by automation.

Common mistakes

Privacy and accuracy notes

Form-factor detection at the coarse mobile/desktop level is privacy-safe. Combining many device details to single out a user is fingerprinting; WebmasterID stays at the broad form-factor level and does not profile individuals.

Frequently asked questions

What is the modern way to detect mobile vs desktop?
Use the Sec-CH-UA-Mobile Client Hint (a low-entropy boolean) with the legacy Mobile token as a fallback, and prefer responsive design so layout adapts to viewport and capability rather than a parsed device guess.

Related pages

Sources and verification notes

Last reviewed 2026-06-24. Facts are checked against primary/official sources where available; uncertain specifics are marked “Data not yet verified” rather than guessed.