Detect macOS browser

Guess whether the device is a Mac, iPhone or iPad from the platform string.

JavaScriptBrowser · DOM Version 1.0.0 · MIT · .md

detect-macos-browser.js
function isApplePlatform() { return /Mac|iPhone|iPad|iPod/.test(navigator.userAgentData?.platform ?? navigator.platform); }

Usage

usage.js
// Headless Chromium on Linux:
isApplePlatform(); // → false
isApplePlatform(); // e.g. true on a Mac, an iPhone or an iPad

Lines marked → were executed in headless Chromium against the markup above, and each result was compared with the value shown. Lines marked e.g. are illustrative.

Know the limits

  • navigator.platform is deprecated, and iPadOS reports "MacIntel" in desktop mode, so this cannot tell a Mac from an iPad. Chromium’s navigator.userAgentData is read where available.
  • Use it for keyboard hints (⌘ versus Ctrl), not for features: detect those directly.

The function above is the code the usage lines run. It does not validate its arguments; add checks where it receives untrusted input.

Source & maintenance

Based on Detect macOS browser from the original 1loc collection by Nguyen Huu Phuoc. Copyright (c) 2020 phuoc-ng. MIT licensed.

Reads navigator.userAgentData where available; platform limits documented. Executed in Chromium. Original MDX retained as inert source evidence.

Maintained by Oveyon. Original source commit: 14b481cf60df. This edition’s file: contents/detect-macos-browser.mdx in akamind/1loc, commit 0a77f131b22d. Read the license.

Usage lines executed in headless Chromium against the fixture markup; no external services · reviewed October 28, 2026.

Keep exploring

Type two or more characters. Try “duplicate”, “webhook” or “retry”.