navigator.userAgent is a read-only property that returns the browser’s User-Agent (UA) string — the same kind of value browsers send in the HTTP User-Agent header (MDN).
Read the notes below before you rely on this property. Prefer feature detection when support is limited.
Syntax
Use navigator.userAgent. Start with this line.
JavaScript
navigator.userAgent
Call
What it does
navigator.userAgent
Primary signature.
Built into the browser. Read navigator.userAgent on Navigator — no import required.
Library declarations
JavaScript
navigator.userAgent
Parameters
This member has no parameters beyond those shown in the signature.
Return Value
Return Value
Description
*
string
JavaScript Examples
Example 1 — Read the User-Agent String
Log the current browser’s UA string (MDN’s basic example).
Service workers supported
Clipboard write available
(messages depend on this browser)
How It Works
Skip name checks. Strings like "Chrome" appear in many browsers.
Ask for the API.in / existence checks answer “can I use this?”
Branch on capability. Enable features only when present.
Keep a fallback. Progressive enhancement beats brittle UA regex.
Compatibility
Browser Support
Navigator.userAgent returns a string. MDN marks it Baseline Widely available (since July 2015). Not Deprecated, Experimental, or Non-standard.
✓ Baseline Widely available
Navigator.userAgent
Supported in all modern browsers and legacy ones. The string format and reduction behavior differ by browser — prefer feature detection for capabilities.
BaselineWidely available
Google ChromeAll versions
Yes
Microsoft EdgeAll versions
Yes
Mozilla FirefoxAll versions
Yes
Apple SafariAll versions
Yes
OperaAll versions
Yes
Internet ExplorerSupported
Yes
userAgentUniversal in browsers
Bottom line: Safe to read everywhere. See the MDN userAgent reference. Do not use it as your primary feature gate.
Frequently Asked Questions
A string — the browser’s User-Agent (UA) string for the current browser. The same kind of value is also sent in the User-Agent HTTP header.
No. MDN marks it Baseline Widely available (since July 2015). It is not Deprecated, Experimental, or Non-standard.
No. MDN says UA sniffing is unreliable. Prefer feature detection. Modern browsers also reduce or freeze parts of the UA string for privacy.
No. It is a read-only Navigator property. You read the string; you do not assign a new value from page script.
The browser also sends a User-Agent header on HTTP requests. navigator.userAgent exposes a UA string to JavaScript in the page.
Check for the capability you need (for example "serviceWorker" in navigator), use progressive enhancement, and consider User-Agent Client Hints (navigator.userAgentData) when you truly need UA metadata.