Detect Tablet Devices from User-Agent
Learn how to detect tablet devices (iPad, Android tablets, Surface) from User-Agent strings. Understand the challenges of tablet detection in modern UA strings.
Detailed Explanation
Detecting Tablets from User-Agent Strings
Tablet detection from UA strings has become increasingly challenging due to changes in how operating systems report themselves.
iPad Detection (Pre-iPadOS 13)
Before iPadOS 13 (2019), iPads were easy to identify:
Mozilla/5.0 (iPad; CPU OS 17_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.2 Mobile/15E148 Safari/604.1
The iPad token in the UA string was unambiguous.
iPad Detection (iPadOS 13+)
Since iPadOS 13, iPad Safari defaults to requesting desktop websites, sending a macOS UA:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.2 Safari/605.1.15
This UA is identical to macOS Safari. The only ways to detect iPads now:
- Check for touch event support (
'ontouchend' in document) - Compare screen dimensions (iPads have specific aspect ratios)
- Use the
navigator.maxTouchPointsAPI (iPads report > 0)
Android Tablet Detection
Android tablets are distinguished from phones by the absence of the Mobile token:
Android Phone:
...Chrome/120.0.0.0 Mobile Safari/537.36
Android Tablet:
...Chrome/120.0.0.0 Safari/537.36
The Mobile keyword is removed for tablets. This is the standard Android convention.
Samsung Galaxy Tab
Mozilla/5.0 (Linux; Android 13; SM-T870) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36
The SM-T prefix in Samsung model numbers indicates a Galaxy Tab.
Surface Tablets
Microsoft Surface tablets running Windows send standard Windows desktop UAs:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36
Surface tablets are indistinguishable from desktop Windows PCs via UA string alone.
Best Practices
For reliable tablet detection, combine UA parsing with client-side feature detection:
- UA parsing → catches Android tablets and legacy iPads
navigator.maxTouchPoints > 0+ macOS UA → likely iPad- Screen size heuristics → fallback for ambiguous cases
Use Case
E-commerce sites adapt their UI for tablet visitors — larger touch targets, different grid layouts, and tablet-optimized checkout flows. Media sites may serve different ad formats for tablets. Analytics teams need accurate device type segmentation to understand usage patterns across phones, tablets, and desktops.