Parse iOS Safari User-Agent String
Parse an iOS Safari User-Agent string to extract the iPhone/iPad model, iOS version, and Safari version. Understand how iOS UA strings differ from macOS.
Detailed Explanation
Understanding iOS User-Agent Strings
iOS Safari has a distinct UA string format that differs from macOS Safari:
iPhone UA String
Mozilla/5.0 (iPhone; CPU iPhone OS 17_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.2 Mobile/15E148 Safari/604.1
iPad UA String
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
Token Breakdown
- (iPhone; CPU iPhone OS 17_2 like Mac OS X) — Device type and iOS version. The
like Mac OS Xsuffix is a legacy token from when iOS was called "iPhone OS." - AppleWebKit/605.1.15 — The WebKit version used by iOS Safari
- Version/17.2 — Safari version, which typically matches the major iOS version
- Mobile/15E148 — iOS build number
Important iOS UA Behavior
All iOS browsers use WebKit. Apple requires every browser on iOS to use its WebKit engine. This means Chrome on iOS, Firefox on iOS, and Edge on iOS all report AppleWebKit in their UA strings and render pages using WebKit, not their desktop engines.
Chrome on iOS:
Mozilla/5.0 (iPhone; CPU iPhone OS 17_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/120.0.6099.119 Mobile/15E148 Safari/604.1
Note CriOS (Chrome iOS) instead of Chrome.
Firefox on iOS:
Mozilla/5.0 (iPhone; CPU iPhone OS 17_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) FxiOS/121.0 Mobile/15E148 Safari/604.1
Note FxiOS (Firefox iOS) instead of Firefox.
iPad with Desktop Mode
Since iPadOS 13, iPad Safari defaults to requesting the desktop site, sending a macOS-style 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 makes iPads indistinguishable from Macs via UA string alone. Touch event detection or screen size checks are needed for accurate iPad identification.
Use Case
Mobile app developers and web developers parse iOS UA strings to detect specific iOS versions for feature gating (e.g., Web Push support added in iOS 16.4, Screen Wake Lock API in iOS 16.4). It is also important for identifying iPads in desktop mode for adaptive UI decisions.