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

Syntax

var lang = navigator.language 

Value

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.

Example

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

Specifications

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

Browser compatibility

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidEdge MobileFirefox for AndroidOpera for AndroidiOS SafariSamsung Internet
Basic supportChrome Full support Yes
Notes
Full support Yes
Notes
Notes Returns the browser UI language, not the value of the Accept-Language HTTP header.
Edge Full support YesFirefox Full support 1
Notes
Full support 1
Notes
Notes Prior to Firefox 4 this property's value was also part of the user agent string, as reported by navigator.userAgent.
Full support 5
Notes
Notes Starting in Firefox 5.0 this property's value is based on the value of the Accept-Language HTTP header.
IE Full support 11
Notes
Full support 11
Notes
Notes Closest available (non-standard) properties are userLanguage and browserLanguage.
Opera Full support YesSafari Full support YesWebView Android Full support Yes
Notes
Full support Yes
Notes
Notes Returns the browser UI language, not the value of the Accept-Language HTTP header.
Chrome Android Full support Yes
Notes
Full support Yes
Notes
Notes Returns the browser UI language, not the value of the Accept-Language HTTP header.
Edge Mobile Full support YesFirefox Android Full support 4Opera Android Full support YesSafari iOS Full support YesSamsung Internet Android ?

Legend

Full support  
Full support
Compatibility unknown  
Compatibility unknown
See implementation notes.
See implementation notes.

See also