JavaScript Navigator language Property

Beginner
5 min read
Updated: Nov 2026
3 examples
Property

Definition

navigator.language is a read-only property that returns a string for the user’s preferred language — usually the browser UI language — as a BCP 47 tag (MDN). Examples: en, en-US, fr-FR.

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

Syntax

Use navigator.language. Start with this line.

JavaScript
navigator.language
CallWhat it does
navigator.languagePrimary signature.

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

Library declarations
JavaScript
navigator.language

Parameters

ParameterDescription
Intl.*Optional. Locale-aware formatting
languagechangeOptional. Fires on window when prefs change

Return Value

Return ValueDescription
*BCP 47 string (e.g. en-US)

JavaScript Examples

Example 1 — Read Language

Log the preferred BCP 47 language tag.

JavaScript
const tag = navigator.language;
console.log(tag);
Try It Yourself

How It Works

  1. Read the property. navigator.language returns a string.
  2. Expect BCP 47. Forms like en or en-US (MDN).
  3. It is read-only. Users change language in browser/OS settings.
  4. Use it as a locale. Pass the tag to Intl or i18n loaders.

Example 2 — vs languages

Compare the single preferred tag with the full preference list.

JavaScript
const primary = navigator.language;
const list = navigator.languages;

console.log("language: " + primary);
console.log("languages[0]: " + list[0]);
console.log("match: " + (primary === list[0]));
Try It Yourself

How It Works

  1. Read both. language is one tag; languages is an array.
  2. Check index 0. MDN: language is typically the first languages entry.
  3. Prefer the array for fallbacks. Offer content in the user’s 2nd/3rd choices.
  4. Expect rare mismatches. Some browsers treat UI language separately from Accept-Language.

Example 3 — Intl Formatting

Format a date with the user’s preferred language (MDN pattern).

JavaScript
const date = new Date("2012-05-24");
const formatted = new Intl.DateTimeFormat(navigator.language).format(date);
console.log(formatted);
Try It Yourself

How It Works

  1. Pick a date. Use a fixed ISO date so the locale effect is clear.
  2. Pass the locale. Intl.DateTimeFormat(navigator.language) (MDN).
  3. Call format. Output follows that locale’s date rules.
  4. Reuse the idea. Same pattern works with NumberFormat and friends.

Browser Support

Navigator.language is Baseline Widely available on MDN (since about July 2015). No Experimental, Deprecated, or Non-standard status.

✓ Baseline Widely available

Navigator.language

Supported across modern Chrome, Edge, Firefox, Safari, and Opera. Safe to use for locale hints without feature detection in current browsers.

Wide Baseline
Google Chrome Full support
Supported
Microsoft Edge Full support
Supported
Mozilla Firefox Full support
Supported
Apple Safari Full support (old iOS case quirk)
Supported
Opera Full support
Supported
navigator.language Wide

Bottom line: Read the BCP 47 tag, pass it to Intl when needed, and use languages when you need a preference list.

Frequently Asked Questions

It is a read-only Navigator property that returns a string for the user’s preferred language — usually the language of the browser UI — in BCP 47 format such as en-US or fr-FR (MDN).
No. MDN marks it Baseline Widely available (since about July 2015). It is not Deprecated, Experimental, or Non-standard.
A BCP 47 language tag. Common examples: en, en-US, fr, fr-FR, es-ES. Older Safari on iOS (before 10.2) used lowercase region codes like en-us.
language is the single preferred language. languages is an array of preferred languages in preference order. The first item in languages is typically the same as language (MDN).
Pass navigator.language to Intl constructors, for example new Intl.DateTimeFormat(navigator.language).format(date), as shown on MDN.
No. It is read-only. Users change preferred language in browser or OS settings; your page only reads the tag.

Next: languages

Learn navigator.languages for the full preference list.

languages 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