Example 1 — Read platform
Log the current platform string.
console.log(navigator.platform);
// Examples: "MacIntel", "Win32", "Linux x86_64" How It Works
Your exact value depends on OS and browser. Treat it as a hint, not absolute truth.

navigator.platform is a read-only string that identifies the platform the browser is running on. Learn common values, why OS sniffing is unreliable, MDN’s ⌘ vs Ctrl shortcut tip, five examples, and try-it labs.
Read-only property
String
Widely available
MacIntel · Win32
Not recommended
Shortcut key labels
navigator.platform answers a short question: what platform string does the browser report? You might see values such as MacIntel, Win32, or Linux x86_64.
That sounds perfect for OS detection — but MDN warns that using platform (or the user agent) to work around bugs is unreliable. Prefer feature detection for real capability checks.
MDN highlights keyboard-shortcut advice: show ⌘ on Apple platforms and Ctrl elsewhere. That is presentation help — not feature gating.
platform PropertyThink of platform as a coarse label the browser exposes about its host environment. You read it; you never assign to it.
MacIntel, Win32, Linux x86_64.Win32 even on 64-bit Windows.Navigator interface.General form of the property:
navigator.platform // Read the string:
console.log(navigator.platform);
// MDN: modifier key hint for shortcuts
const modifierKeyPrefix =
navigator.platform.startsWith("Mac") || navigator.platform === "iPhone"
? "⌘"
: "Ctrl";
// Prefer this for real features:
if ("serviceWorker" in navigator) {
// Use Service Workers — do not sniff platform instead
} | Goal | Code |
|---|---|
| Read platform | navigator.platform |
| Looks like Mac? | navigator.platform.startsWith("Mac") |
| iPhone exact match | navigator.platform === "iPhone" |
| Shortcut prefix (MDN) | Mac / iPhone ? "⌘" : "Ctrl" |
| Writable? | No (read-only) |
| Status (MDN) | Baseline Widely available |
Four facts to remember about navigator.platform.
stringPlatform label
widelySince July 2015
Win32Even on 64-bit
feature detectNot OS sniffing
platform vs Feature Detectionnavigator.platform | Feature detection | |
|---|---|---|
| Question | “What platform string is reported?” | “Does this API exist here?” |
| Reliability for bugs | Low (MDN discourages sniffing) | High for capability checks |
| Good for | Shortcut key labels (⌘ / Ctrl) | Enabling Service Workers, WebRTC, etc. |
| Example | startsWith("Mac") | "serviceWorker" in navigator |
| Use together? | Yes — optional UI hints from platform; real features from detection | |
Examples follow MDN navigator.platform guidance. Prefer Try It Yourself to see your browser’s string.
Read the string and apply MDN’s modifier-key pattern.
platformLog the current platform string.
console.log(navigator.platform);
// Examples: "MacIntel", "Win32", "Linux x86_64" Your exact value depends on OS and browser. Treat it as a hint, not absolute truth.
Choose ⌘ on Apple platforms and Ctrl elsewhere.
const modifierKeyPrefix =
navigator.platform.startsWith("Mac") || navigator.platform === "iPhone"
? "⌘" // command key
: "Ctrl"; // control key
console.log("Save shortcut hint: " + modifierKeyPrefix + "+S"); This is MDN’s recommended practical use: UI advice for shortcuts, not feature detection.
Windows quirks, type checks, and preferring real capability detection.
Win32 NoteDo not assume Win32 means a 32-bit OS.
const p = navigator.platform;
if (p === "Win32") {
console.log("Reports Win32 (common even on 64-bit Windows)");
} else {
console.log("platform: " + p);
} MDN documents this Windows quirk explicitly — another reason sniffing bitness from platform fails.
Beginner sanity check for the property type.
const lines = [
"value: " + navigator.platform,
"typeof: " + typeof navigator.platform
];
console.log(lines.join("\n")); You always get a string (when the property is present in normal browsers).
Keep platform for labels; use capability checks for features.
const lines = [];
lines.push(
"platform: " + navigator.platform + " — OK for shortcut labels"
);
lines.push(
"serviceWorker: " +
("serviceWorker" in navigator ? "available" : "missing") +
" — use this for features"
);
console.log(lines.join("\n")); Matches MDN advice: do not use platform to work around missing features — detect the features themselves.
platform in optional debug panels.Win32 is not proof of 32-bit Windows.navigator.platform WorksThe engine reports a platform string on navigator.
Values like MacIntel or Win32.
Use carefully for shortcut labels (⌘ / Ctrl).
Gate APIs with in checks, not platform sniffing.
Navigator.Win32 even on 64-bit systems.navigator.platform is Baseline Widely available across modern browsers (MDN: since July 2015). Use it sparingly for UI hints; prefer feature detection for real capabilities.
Read the platform string for optional shortcut labels. Do not rely on it for OS sniffing or feature branching.
Bottom line: Read navigator.platform for labels if needed, remember the Win32 quirk, and detect features instead of sniffing the OS.
navigator.platform is a Baseline string naming the reported platform. Use MDN’s ⌘ / Ctrl pattern for shortcut help when useful, avoid OS sniffing for features, and remember that Win32 is common even on 64-bit Windows.
Continue with preferences, permissions, or the JavaScript hub.
Win32 quirkWin32 means 32-bit Windowsnavigator.platformoscpu stringplatformBaseline platform string — labels OK, sniffing not.
string
Type⌘ / Ctrl hints
UXoften Win32
Quirkread-only
APIfeature detect
ModernBrowsers are reducing how much environment detail they leak (user-agent reduction and related privacy work). That makes platform sniffing even less dependable over time — another vote for feature detection.
Experimental User Preferences API via PreferenceManager.
8 people found this page helpful