JavaScript Navigator oscpu Property

Beginner
5 min read
Updated: Nov 2026
5 examples
Property

Definition

navigator.oscpu is a read-only Navigator property that returns a string identifying the operating system when the browser exposes it (MDN). Support is mainly Firefox / Gecko; elsewhere it is often missing.

Read the notes below before you rely on this property. Prefer feature detection when support is limited.

Syntax

Use navigator.oscpu. Start with this line.

JavaScript
navigator.oscpu
CallWhat it does
navigator.oscpuPrimary signature.

Built into the browser. Read navigator.oscpu on Navigator — no import required.

Library declarations
JavaScript
navigator.oscpu

Parameters

ParameterDescription
"oscpu" in navigatorRequired. Feature detect

Return Value

Return ValueDescription
*The current value of navigator.oscpu.

JavaScript Examples

Example 1 — Feature Detection

Check whether this browser exposes a usable oscpu string.

JavaScript
const supported =
  "oscpu" in navigator && Boolean(navigator.oscpu);

console.log(supported ? "oscpu available" : "oscpu missing");
Try It Yourself

How It Works

  1. Use in. Confirms the property exists on navigator.
  2. Check truthiness. Empty / undefined values fail the second part.
  3. Expect gaps. Chromium/Safari often report missing.
  4. Guard before reading. Avoid assuming a string in every browser.

Example 2 — Read oscpu (MDN)

MDN-style helper that surfaces the OS string when present.

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

osInfo();
// e.g. "Windows NT 6.0" in some Firefox setups (MDN)
Try It Yourself

How It Works

  1. Guard first. Skip when the property is absent.
  2. Log the string. MDN’s osInfo idea, without alert.
  3. Shapes vary. Windows / macOS / Linux formats differ (MDN table).
  4. Demo only. Do not parse this for production branching.

Example 3 — Safe Read Helper

Return a structured result instead of throwing or assuming support.

JavaScript
function readOscpu() {
  if (!("oscpu" in navigator) || !navigator.oscpu) {
    return { ok: false, reason: "unsupported" };
  }
  return { ok: true, value: String(navigator.oscpu) };
}

console.log(JSON.stringify(readOscpu(), null, 2));
Try It Yourself

How It Works

  1. Return an object. Easy to branch without exceptions.
  2. unsupported path. Common on Chromium/WebKit.
  3. Stringify the value. Keeps the success shape predictable.
  4. Still a hint. Overrides can make ok: true lie about the OS.

Example 4 — vs platform

Compare the Firefox-oriented string with the wider platform property.

JavaScript
const oscpu =
  "oscpu" in navigator && navigator.oscpu
    ? String(navigator.oscpu)
    : "(missing)";

console.log("oscpu: " + oscpu);
console.log("platform: " + navigator.platform);
console.log("Neither is reliable for OS sniffing");
Try It Yourself

How It Works

  1. Normalize missing. Print (missing) when oscpu is absent.
  2. Read platform. Wider support; still coarse and spoofable.
  3. Compare side by side. Useful when studying legacy sniffing code.
  4. Same warning. Neither string should gate production features.

Example 5 — Prefer Feature Detection

Show the teaching pattern: detect APIs, do not parse OS names.

JavaScript
function choosePath() {
  // Bad: if (navigator.oscpu.includes("Windows")) { … }
  // Good: test the capability you need
  if ("serviceWorker" in navigator) {
    return "can use service workers";
  }
  return "no service workers — use a fallback";
}

console.log(choosePath());
console.log(
  "oscpu present: " +
    Boolean("oscpu" in navigator && navigator.oscpu)
);
Try It Yourself

How It Works

  1. Skip OS parsing. Commented “bad” path shows what to avoid.
  2. Test the API. "serviceWorker" in navigator is capability-based.
  3. Return a clear path. Easy to log or assert in demos.
  4. Log oscpu only as context. Not as the decision maker.

Browser Support

navigator.oscpu is not Baseline. Useful support is mainly Firefox / Gecko. Other engines often omit it — always feature-detect.

✓ Limited · Firefox-oriented

Navigator.oscpu

Expect a string in Firefox. Treat Chromium, Safari, Edge, and Opera as usually unsupported for this property.

35% Practical cross-browser reach
Mozilla Firefox oscpu · primary support
Supported
Google Chrome Typically missing / unused
Unavailable
Microsoft Edge Typically missing / unused
Unavailable
Apple Safari Typically missing / unused
Unavailable
Opera Typically missing / unused
Unavailable
Internet Explorer Not a reliable oscpu source
Unavailable
navigator.oscpu Limited

Bottom line: Learning / Firefox demos only. Prefer feature detection (and wider hints like platform) instead of OS sniffing.

Frequently Asked Questions

When present, a string that identifies the operating system (for example a Windows NT … or Linux … style value). Often missing outside Firefox/Gecko (MDN).
MDN treats it as a limited, Firefox-oriented Navigator property — not Baseline. Prefer not to rely on it in production. It is not typically labeled Experimental; treat it as non-portable.
Support is strongest in Firefox/Gecko. Chrome, Edge, Safari, and Opera typically omit a useful value. Always feature-detect.
Yes in Firefox: non-privileged pages may see the general.oscpu.override preference instead of the true platform string (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.

Next: pdfViewerEnabled

Learn how navigator.pdfViewerEnabled reports inline PDF viewing support.

pdfViewerEnabled tutorial →

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.

10 people found this page helpful