JavaScript Navigator oscpu Property

Beginner
⏱️ 9 min read
📚 Updated: Jul 2026
🎯 5 Examples
🚀 5 Try-it labs
Non-standard

What You’ll Learn

navigator.oscpu returns a string that identifies the current operating system when the browser exposes it. Learn MDN’s example, typical OS string shapes, feature detection, preference overrides, why sniffing is brittle, five examples, and try-it labs.

01

Kind

Read-only property

02

Returns

String (when present)

03

Status

Non-standard

04

Main engine

Gecko / Firefox

05

Means

OS identity hint

06

Production?

Avoid relying

Introduction

The name oscpu comes from older browser APIs that tried to answer: “what operating system / CPU platform is this?” On supporting browsers it returns a human-readable OS string.

Today that answer is incomplete across the web. Chromium and Safari typically do not expose a useful oscpu, and even in Firefox the string can be overridden for privacy or testing.

💡
Learn it, don’t depend on it

Use this tutorial to understand legacy Navigator OS strings and to practice feature detection. For real apps, detect capabilities (for example "serviceWorker" in navigator) instead of sniffing the OS.

Understanding the oscpu Property

When available, reading navigator.oscpu gives a string describing the OS. MDN documents common formats such as Windows NT x.y; Win64; x64 or Linux uname-style output.

  • Read-only — you inspect; you do not assign.
  • Non-standard — limited, engine-specific support.
  • May be missing — treat absence as normal on many browsers.
  • May be overridden — Firefox general.oscpu.override can replace the true value for non-privileged pages.

📝 Syntax

General form of the property:

JavaScript
navigator.oscpu

Value

  • A string identifying the operating system when supported.
  • Often undefined / absent outside Gecko.

Common patterns

JavaScript
// Always feature-detect first
if ("oscpu" in navigator && navigator.oscpu) {
  console.log(navigator.oscpu);
} else {
  console.log("oscpu not available");
}

// MDN-style helper:
function osInfo() {
  return navigator.oscpu;
}

⚡ Quick Reference

GoalCode
Read OS stringnavigator.oscpu
Feature detect"oscpu" in navigator
Safe readnavigator.oscpu || "(absent)"
Type checktypeof navigator.oscpu === "string"
Writable?No (read-only)
Status (MDN)Non-standard

🔍 At a Glance

Four facts to remember about navigator.oscpu.

Returns
string

OS identity

Status
non-standard

Limited engines

Access
read-only

No assignment

Best for
learning

Not production sniff

📋 oscpu vs Feature Detection

navigator.oscpuFeature detection
Question answered“What OS string does the browser report?”“Does this API exist here?”
PortabilityWeak (non-standard)Strong across engines
Can be spoofed / overridden?Yes (prefs / privacy)Usually honest about capability presence
Best forLearning / legacy debuggingProduction branching
Examplenavigator.oscpu"serviceWorker" in navigator

📋 Common oscpu String Shapes (MDN)

Examples of formats MDN documents. Your browser may differ or omit the property entirely.

Operating systemTypical string shape
Windows 64-bit (64-bit build)Windows NT x.y; Win64; x64
Windows 64-bit (32-bit build)Windows NT x.y; WOW64
Windows 32-bitWindows NT x.y
macOS / Mac OS XIntel Mac OS X or macOS version x.y
LinuxOften uname -sm style output

Examples Gallery

Examples follow MDN navigator.oscpu patterns with safe detection. Prefer Try It Yourself in Firefox to see a real string; Chromium often shows “missing.”

📚 Getting Started

Detect support and read the OS string safely.

Example 1 — Feature Detection

Check whether oscpu exists before trusting it.

JavaScript
const supported = "oscpu" in navigator && !!navigator.oscpu;
console.log(supported ? "oscpu available" : "oscpu missing");
Try It Yourself

How It Works

Checking both in and a truthy value avoids treating empty strings as useful OS data.

Example 2 — MDN-Style osInfo()

Read and log the property when present (MDN uses alert; we use console.log).

JavaScript
function osInfo() {
  if (!("oscpu" in navigator) || !navigator.oscpu) {
    console.log("oscpu not supported");
    return;
  }
  console.log(navigator.oscpu);
}

osInfo();
// Example on some Firefox builds: "Windows NT 10.0; Win64; x64"
Try It Yourself

How It Works

Same idea as MDN’s demo, with a guard so unsupported browsers print a clear message.

📈 Practical Patterns

Parse common shapes, remember overrides, prefer real capability checks.

Example 3 — Spot Common Windows Tokens

Lightweight pattern hints from MDN’s format table (not for production sniffing).

JavaScript
function describeOscpu() {
  if (!navigator.oscpu) return "missing";
  const s = String(navigator.oscpu);
  const hints = [];
  if (/Windows NT/i.test(s)) hints.push("windows-nt");
  if (/Win64|x64/i.test(s)) hints.push("64-bit-tokens");
  if (/WOW64/i.test(s)) hints.push("wow64");
  if (/Linux|Mac OS|macOS/i.test(s)) hints.push("unix-like-tokens");
  return "value=" + s + "; hints=" + (hints.join(",") || "none");
}

console.log(describeOscpu());
Try It Yourself

How It Works

Useful for learning string shapes. Do not gate product features on these regexes.

Example 4 — Remember Preference Overrides

MDN: non-privileged code may see general.oscpu.override instead of the true OS.

JavaScript
function oscpuTrustNote() {
  if (!navigator.oscpu) {
    return "No oscpu — cannot trust or distrust a missing value.";
  }
  return (
    "Got: " +
    navigator.oscpu +
    " — treat as untrusted (prefs / privacy may override)."
  );
}

console.log(oscpuTrustNote());
Try It Yourself

How It Works

Even a present string is not proof of the real OS — overrides exist on purpose.

Example 5 — Prefer Feature Detection

Do not gate features on oscpu.

JavaScript
const lines = [];
lines.push(
  "oscpu: " +
    (navigator.oscpu ? navigator.oscpu : "(absent)") +
    " — ignore for sniffing"
);
lines.push(
  "serviceWorker: " +
    ("serviceWorker" in navigator ? "available" : "missing")
);
lines.push(
  "onLine: " + String(navigator.onLine)
);
console.log(lines.join("\n"));
Try It Yourself

How It Works

Capability checks stay correct even when OS strings are missing, overridden, or lying.

🚀 Common Use Cases

  • Learning Navigator — see a classic non-standard OS string API.
  • Legacy Firefox debugging — understand old OS-report reads.
  • Privacy / override education — show why OS sniffing is untrusted.
  • Not for production branching — prefer feature detection.
  • Not for fingerprinting — avoid collecting brittle identity signals.

🧠 How oscpu Works

1

Engine may expose the property

Non-standard — often present in Firefox, absent elsewhere.

Expose?
2

Build an OS string

Formats like Windows NT … or Linux uname output.

String
3

Prefs may replace it

Firefox can serve general.oscpu.override instead.

Override
4

Apps should ignore it

Detect APIs you need; do not sniff the OS via oscpu.

📝 Notes

  • Non-standard — primarily a Gecko/Firefox-oriented Navigator property (MDN).
  • Not Baseline; many engines omit it.
  • Read-only string when present.
  • May reflect general.oscpu.override instead of the true platform.
  • Do not use for production OS sniffing or fingerprinting.
  • Related: onLine, buildID, appVersion, Window.

Limited / Non-standard Support

navigator.oscpu is non-standard and not universally implemented. Support is strongest in Firefox/Gecko; Chrome, Edge, Safari, and Opera typically omit a useful value. Always feature-detect.

Non-standard · Limited

Navigator.oscpu

Safe to explore for learning. Do not rely on OS sniffing for production feature branching.

Limited Non-standard
Mozilla Firefox May expose oscpu (prefs can override)
Limited
Google Chrome Typically no useful navigator.oscpu
Unavailable
Microsoft Edge Typically no useful navigator.oscpu
Unavailable
Apple Safari Typically no useful navigator.oscpu
Unavailable
Opera Typically no useful navigator.oscpu
Unavailable
Internet Explorer Not a modern portable target for oscpu
Unavailable
oscpu Limited

Bottom line: Feature-detect if you must read oscpu. Prefer API feature detection for real application logic. Remember Firefox preference overrides.

Conclusion

navigator.oscpu is a non-standard OS identification string with limited, Gecko-oriented support. Learn the MDN shapes and always feature-detect — then prefer real capability checks for production code.

Continue with pdfViewerEnabled, onLine, or Window methods.

💡 Best Practices

✅ Do

  • Feature-detect before reading oscpu
  • Treat values as possibly overridden
  • Use feature detection for capabilities
  • Document non-standard usage in legacy code
  • Prefer standards-based Navigator APIs

❌ Don’t

  • Assume every browser exposes oscpu
  • Gate downloads or UI on OS regexes
  • Use it for fingerprinting
  • Confuse Non-standard with Baseline support
  • Trust the string as absolute OS truth

Key Takeaways

Knowledge Unlocked

Five things to remember about oscpu

Non-standard OS string — often missing or overridden.

5
Core concepts
🔍 02

Detect

"oscpu" in navigator

Safe
⚠️ 03

Status

non-standard

Legacy
🔒 04

Override

prefs possible

Caution
🎯 05

Prefer

feature detect

Modern

❓ Frequently Asked Questions

When present, it returns a string that identifies the operating system the browser is running on — for example a Windows NT … or Linux … style value. The property is non-standard and often missing outside Gecko/Firefox.
MDN lists it as a non-standard Navigator property (Gecko-oriented). It is not Baseline. Prefer not to rely on it in production. It is not typically labeled Experimental.
Support is strongest in Firefox/Gecko. Chrome, Edge, Safari, and Opera typically return undefined / omit useful support. Always feature-detect.
Yes in Firefox: non-privileged pages may see the general.oscpu.override preference instead of the true platform string (per MDN usage notes).
No. Prefer feature detection for the APIs you need. OS strings are incomplete across browsers, can be overridden, and encourage brittle sniffing.
No. It is a read-only Navigator property when it exists.
Did you know?

The name oscpu dates back to older Netscape / Gecko APIs that exposed “OS + CPU” style platform information. Modern privacy guidance prefers not to leak fine-grained environment details to every website.

Learn pdfViewerEnabled Next

Baseline Boolean for inline PDF viewing support.

pdfViewerEnabled →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful