JavaScript Navigator hardwareConcurrency Property

Beginner
5 min read
Updated: Nov 2026
3 examples
Property

Definition

navigator.hardwareConcurrency is a read-only number: how many logical processors can run threads on this device (MDN). Use it as a hint when sizing Web Worker pools.

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

Syntax

Use navigator.hardwareConcurrency. Start with this line.

JavaScript
navigator.hardwareConcurrency
CallWhat it does
navigator.hardwareConcurrencyPrimary signature.

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

Library declarations
JavaScript
navigator.hardwareConcurrency

Parameters

ParameterDescription
FallbackOptional. Default when missing in old engines
WorkersOptional. Run heavy work off the main thread

Return Value

Return ValueDescription
*Number ≥ 1 (logical processors)

JavaScript Examples

Example 1 — Read hardwareConcurrency

Log the reported logical processor count.

JavaScript
console.log(navigator.hardwareConcurrency);
// e.g. 8 on a typical hyper-threaded laptop
Try It Yourself

How It Works

  1. Read the property. No arguments — just navigator.hardwareConcurrency.
  2. Expect a number. MDN: at least 1, up to the logical processor count.
  3. Treat it as a hint. Useful for parallelism, not exact hardware inventory.
  4. Baseline support. Safe in modern browsers without special flags.

Example 2 — Clamp a Worker Pool Size

Use a fallback and a max cap so you never spawn too many Workers.

JavaScript
function workerPoolSize() {
  const cores = navigator.hardwareConcurrency || 4;
  return Math.max(1, Math.min(cores, 8));
}

console.log("pool size: " + workerPoolSize());
Try It Yourself

How It Works

  1. Read with fallback. || 4 covers rare missing cases.
  2. Clamp with Math.min. Avoid huge pools on high-core machines.
  3. Ensure at least one. Math.max(1, …) keeps a valid size.
  4. Use for Workers. Create that many reusable workers, not more.

Example 3 — MDN-Style Worker List Shape

Build a pool record list (one slot per logical processor) — MDN pattern, without spawning files here.

JavaScript
const workerList = [];
const n = navigator.hardwareConcurrency || 4;

for (let i = 0; i < n; i++) {
  workerList.push({
    id: i,
    inUse: false
    // worker: new Worker("cpu-worker.js")  // real apps
  });
}

console.log("slots: " + workerList.length);
Try It Yourself

How It Works

  1. Decide pool length. Use concurrency (with a fallback).
  2. Loop once per slot. Same shape as MDN’s worker pool example.
  3. Track inUse. Mark busy workers when processing jobs.
  4. Add real Workers in apps. Point new Worker(…) at your script URL.

Browser Support

Navigator.hardwareConcurrency is Baseline Widely available on MDN (since about March 2022). It is not Deprecated, Experimental, or Non-standard.

✓ Baseline · Widely available

Navigator.hardwareConcurrency

Supported in modern Chrome, Edge, Firefox, Safari, and Opera. Use a small fallback only if you still target very old environments.

95% Modern browser support
Google Chrome All versions · Desktop & Mobile
Full support
Mozilla Firefox All versions · Desktop & Mobile
Full support
Apple Safari All versions · macOS & iOS
Full support
Microsoft Edge All versions · Chromium & Legacy
Full support
Internet Explorer IE 6+ · Legacy environments
Full support
Opera All modern versions
Full support
navigator.hardwareConcurrency Excellent

Bottom line: Read the number, clamp a Worker pool size, and treat it as a concurrency hint — not an exact core inventory.

Frequently Asked Questions

It is a read-only Navigator property that returns the number of logical processors available to run threads on the user’s computer — useful for sizing Web Worker pools (MDN).
No. MDN marks it Baseline Widely available (since about March 2022). It is not Deprecated, Experimental, or Non-standard.
Not necessarily. It reports logical processors (often higher than physical cores because of hyper-threading). The browser may also report a lower number that better matches how many Workers can run at once.
A common pattern is to create one Worker per logical processor (or slightly fewer, with a max cap) so heavy work can run in parallel without oversubscribing the CPU.
The property is Baseline, but a fallback like Math.max(1, navigator.hardwareConcurrency || 4) or a fixed default of 4 is a common defensive habit in older code.
No. It is read-only. You read the number; you cannot change the reported concurrency.

Next: hid

Learn the WebHID API entry via navigator.hid.

hid 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.

11 people found this page helpful