The NavigatorLanguage.language read-only property returns a string representing the preferred language of the user, usually the language of the browser UI.


var lang = navigator.language 


A DOMStringlang stores a string representing the language version as defined in BCP 47. Examples of valid language codes include "en", "en-US", "fr", "fr-FR", "es-ES", etc.

Note that in Safari on macOS and iOS prior to 10.2, the country code returned is lowercase: "en-us", "fr-fr" etc.


if (window.navigator.language != 'en') {       


Specification Status Comment
HTML Living Standard
The definition of 'NavigatorLanguage: language' in that specification.
Living Standard Initial definition

Browser compatibility

FeatureChromeEdgeFirefoxInternet ExplorerOperaSafari
Basic support Yes1 Yes



114 Yes Yes
FeatureAndroid webviewChrome for AndroidEdge mobileFirefox for AndroidOpera AndroidiOS SafariSamsung Internet
Basic support Yes1 Yes1 Yes4 Yes Yes ?

1. Returns the browser UI language, not the value of the Accept-Language HTTP header.

2. Prior to Firefox 4 this property's value was also part of the user agent string, as reported by navigator.userAgent.

3. Starting in Firefox 5.0 this property's value is based on the value of the Accept-Language HTTP header.

4. Closest available (non-standard) properties are userLanguage and browserLanguage.

See also