JavaScript Navigator hardwareConcurrency Property

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

What You’ll Learn

navigator.hardwareConcurrency returns how many logical processors the browser reports. Learn physical vs logical cores, Worker pool sizing, safe caps, five examples, and try-it labs.

01

Kind

Read-only property

02

Returns

Number

03

Baseline

Widely available

04

Means

Logical CPUs

05

Use

Worker pools

06

Range

1 … N

Introduction

Heavy JavaScript on the main thread freezes the UI. Web Workers move work off the main thread — and the next question is: how many workers should I start?

navigator.hardwareConcurrency answers with a number: the logical processors available to run threads. A four-core CPU might report 8 if each core runs two threads. That number is a practical hint for parallel Worker pools.

💡
Hint, not a lab measurement

MDN notes the browser may report a lower count than the true hardware so it better matches how many Workers can run well at once. Treat it as guidance, not an absolute core census.

Understanding the hardwareConcurrency Property

Think of it as “how many threads can usefully run at once before they start fighting for the same cores?”

  • Logical processors — often higher than physical cores (hyper-threading / SMT).
  • Value — a number from 1 up to the reported logical count.
  • Browser discretion — may under-report for a more realistic Worker budget.
  • Main use — size a Worker pool (MDN’s classic example).
  • Baseline — Widely available across modern browsers (MDN, since about March 2022).

📝 Syntax

General form of the property:

JavaScript
navigator.hardwareConcurrency

Value

  • A number between 1 and the number of logical processors the user agent reports.

Common patterns

JavaScript
// Read the count:
console.log(navigator.hardwareConcurrency);

// Cap workers so a 32-core machine does not spawn 32 Workers:
const workers = Math.min(navigator.hardwareConcurrency || 4, 8);

// MDN-style pool sketch:
const workerList = [];
for (let i = 0; i < navigator.hardwareConcurrency; i++) {
  workerList.push({ id: i, inUse: false });
}

⚡ Quick Reference

GoalCode
Read logical CPUsnavigator.hardwareConcurrency
Type checktypeof navigator.hardwareConcurrency === "number"
Safe defaultnavigator.hardwareConcurrency || 4
Cap pool sizeMath.min(navigator.hardwareConcurrency, 8)
Leave one core freeMath.max(1, navigator.hardwareConcurrency - 1)
Status (MDN)Baseline Widely available

🔍 At a Glance

Four facts to remember about navigator.hardwareConcurrency.

Returns
number

Logical CPUs

Baseline
widely

Since ~Mar 2022

Exact?
no

May under-report

Best for
Worker pools

Parallel work

📋 hardwareConcurrency vs deviceMemory

hardwareConcurrencydeviceMemory
MeasuresLogical CPU threadsApproximate RAM (GiB)
TypeNumber (cores)Number (GiB buckets)
BaselineWidely availableNot Baseline (limited)
Typical useHow many WorkersHow heavy the page can be
Combine?Yes — low cores and low memory → lighter workload

Examples Gallery

Examples follow MDN navigator.hardwareConcurrency patterns for reading cores and sizing Worker pools. Prefer Try It Yourself to see your machine’s reported count.

📚 Getting Started

Read the count and turn it into a friendly message.

Example 1 — Read Logical Processors

Log the number of logical processors the browser reports.

JavaScript
console.log(navigator.hardwareConcurrency);
console.log("type: " + typeof navigator.hardwareConcurrency);
Try It Yourself

How It Works

The value is a real number, not a string. Typical laptops often show 4, 8, or 12.

Example 2 — Human-Readable Label

Explain the count for a debug panel or settings screen.

JavaScript
const cores = navigator.hardwareConcurrency;
console.log(
  "About " + cores + " logical processor" +
  (cores === 1 ? "" : "s") + " available"
);
Try It Yourself

How It Works

Say “logical processors” in UI copy — users often confuse that with physical cores.

📈 Practical Patterns

Caps, Worker pool plans, and adaptive tiers.

Example 3 — Cap the Worker Count

Use the reported cores, but never spawn more than a sane maximum.

JavaScript
const MAX = 8;
const poolSize = Math.min(
  Math.max(1, navigator.hardwareConcurrency || 4),
  MAX
);
console.log("pool size: " + poolSize);
Try It Yourself

How It Works

High-core machines can report 16+. Capping avoids memory spikes from dozens of Workers.

Example 4 — Worker Pool Plan (MDN Style)

Build a pool record for each logical processor — same idea as MDN’s Worker example.

JavaScript
const workerList = [];

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

console.log("planned workers: " + workerList.length);
console.log(JSON.stringify(workerList.slice(0, 3)));
Try It Yourself

How It Works

MDN stores each Worker plus an inUse flag so you can hand out idle workers for jobs later.

Example 5 — Adaptive Parallelism Tier

Map cores to a simple low / medium / high strategy for heavy tasks.

JavaScript
function concurrencyTier() {
  const n = navigator.hardwareConcurrency || 4;
  let tier = "medium";
  if (n <= 2) tier = "low";
  else if (n >= 8) tier = "high";
  return {
    cores: n,
    tier: tier,
    workers: tier === "low" ? 1 : tier === "medium" ? 2 : Math.min(n, 6)
  };
}

console.log(JSON.stringify(concurrencyTier()));
Try It Yourself

How It Works

Combine with deviceMemory when you also need a memory-aware “go light” path.

🚀 Common Use Cases

  • Worker pools — size parallel workers for image / data processing (MDN pattern).
  • Encoding / compression — split chunks across a capped worker count.
  • Game / simulation loops — offload physics or AI to N workers.
  • Adaptive quality — fewer parallel jobs on 2-core devices.
  • Diagnostics — show reported concurrency in a “About this device” panel.

🧠 How navigator.hardwareConcurrency Works

1

Hardware has cores & threads

Physical cores often expose multiple logical processors.

CPU
2

Browser reports a number

hardwareConcurrency may match or under-report for Workers.

Report
3

You size a pool

Create up to N Workers (often with a max cap).

Pool
4

Parallel work stays smooth

Heavy jobs leave the main thread free for UI.

📝 Notes

  • Baseline Widely available (MDN, since about March 2022).
  • Not Deprecated, Experimental, or Non-standard — no status banner required.
  • Reports logical processors — not always physical core count.
  • Browsers may under-report; do not treat the value as absolute hardware truth.
  • Related: hid, deviceMemory, JavaScript hub.

Universal Browser Support

navigator.hardwareConcurrency is Baseline Widely available across modern browsers (MDN: since about March 2022). Use it to size Worker pools, and still apply a max cap for safety.

Baseline · Widely available

Navigator.hardwareConcurrency

Read the logical processor count, cap your Worker pool, and keep heavy work off the main thread.

Universal Widely available
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
hardwareConcurrency Excellent

Bottom line: Use hardwareConcurrency as a Worker-sizing hint. Cap the pool and leave headroom for the UI thread.

Conclusion

navigator.hardwareConcurrency tells you how many logical processors the browser thinks you can use. Size Worker pools from that number, apply a sensible cap, and remember the value may be lower than “real” hardware cores.

Continue with hid, deviceMemory, or the JavaScript hub.

💡 Best Practices

✅ Do

  • Use it to size Web Worker pools
  • Cap the maximum Workers (e.g. 6–8)
  • Leave headroom for the UI thread when possible
  • Combine with memory / network hints for heavy jobs
  • Terminate idle Workers when you are done

❌ Don’t

  • Assume it equals physical core count
  • Spawn dozens of Workers on high-core PCs
  • Block the main thread “because Workers exist”
  • Ignore Worker errors and cleanup
  • Use it as a unique device fingerprint

Key Takeaways

Knowledge Unlocked

Five things to remember about hardwareConcurrency

Baseline logical-CPU count for Worker pool sizing.

5
Core concepts
02

Means

Logical CPUs

Threads
👥 03

Use

Worker pools

Parallel
📈 04

Tip

Cap the max

Safety
05

Status

Baseline

Wide

❓ 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.
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.
Did you know?

MDN’s example creates one Worker per reported logical processor and tracks an inUse flag — a tiny thread pool you can reuse for many jobs without spawning a new Worker every time.

Explore hid Next

Learn the WebHID API for talking to HID devices in the browser.

hid →

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