How to detect Browser and Operating System Name and Version using JavaScript

There are times when you need to know what browser and operating system the user is using so as to display CSS and javaScript code correctly. There are many javascript libraries that are available that lets you detect them, one of such library are detect.js released under MIT License.

detect.js file uses navigator.userAgent to detect the browser details and navigator.platform to detect operating system details.

Browsers Supported :
Internet Explorer 6, 7, 8, 9,10+ Mobile
Firefox 3.6, 4, 5, 6, 7+ Mobile
Safari 3, 4, 5+ Mobile
Opera 9, 10, 11+ Mini, Mobile
Chrome, Mobile

This script is able to detect the following Operating systems :

Mac OS X
Example :
<title>Detect Browser and OS details </title>


<script src="detect.js">
    document.write("Browser : " + window.ui.browser);
    document.write("Browser version : " + window.ui.version);
    document.write("Operating System : " + window.ui.os);
    document.write("Operating System version : " + window.ui.osversion);


Output Example:
Browser : Chrome
Browser version : 83.0.4103.97
Operating System : Windows
Operating System version: undefined
Try Out Code2care Dev Tools:


Code2care is an initiative to publish and share varied knowledge in programming and technical areas gathered during day-to-day learnings and development activities.

Students and software developers can leverage this portal to find solutions to their various queries without re-inventing the wheel by referring to our easy to understand posts. Technical posts might include learnings, tutorials, trouble-shooting steps, video tutorials, code snippets, how-to, blogs, articles, etc.

🎉 We are celebrating the 10th years of Code2care! Thank you for all your support!

We strongly support Gender Equality & Diversity.