How to find a user's browser platform using JS

A user’s browser platform refers to the operating system and hardware architecture their web browser is running.

This includes the following types of devices:

  • Desktop

  • Laptop

  • Tablet

  • Smartphone

The operating systems that are used commonly include Windows, macOS, Linux, iOS, and Android.

The browser platform information can be helpful for web developers to optimize their website’s performance and user experience on different platforms. For example, a website may need to use different codes or display different content for users on a mobile device compared to those on a desktop computer.

JavaScript is beneficial for such tasks as it is a client-side language, so we can get all the client's information using JavaScript.

Finding the site user’s browser platform

Let's see how to get a site user’s browser platform using JavaScript:

Web developers can use JavaScript and the navigator.userAgent property to detect a user's browser platform.

const platform = navigator.userAgent;
console.log("User's platform is:", platform);

This property returns a string that represents the user’s platform, such as Win32 for Windows, MacIntel for macOS, and Linux x86_64 for Linux. We can use this information to customize the user experience on our website based on the user’s platform. For example, we can display different messages or UI elements for Windows, macOS, or Linux users. Knowing the user’s platform can also help us optimize our website’s performance by targeting specific platforms for testing and optimization.

Here’s a code snippet that shows how to get the user’s browser platform:

Note: The .navigator object provide many other properties like:

We can read about them in detail on JavaScript official documentation.

Free Resources

Copyright ©2025 Educative, Inc. All rights reserved