64 bit – Detect 64-bit or 32-bit Windows from User Agent or Javascript?-ThrowExceptions

Exception or error:

I want to offer the right version of a download. The versions I have are:

  • 32-bit Windows
  • 64-bit Windows
  • Linux

Detecting Linux using the User Agent field is easy; but is it possible to reliably figure out if Windows is 32-bit or 64-bit?

Users might be using weird browsers – IE and Firefox are common, and we probably have an Opera user somewhere; maybe a Chrome user too. I know that 64-bit Windows 7 ships with 32-bit and 64-bit versions of IE, and I’d like to send them both the 64-bit version of my download.

(Edited to add: I know that I should provide all the options, and I will. But people don’t read the options. So I wanted to provide the right download by default, to improve usability. Of course, while this is helpful if I get it right, it’s extremely unhelpful if I get it wrong. And from the answers so far, it doesn’t look like there’s a reliable way of doing this).

How to solve:

Try this, looks for WOW64 (32-bit on 64-bit) or Win64 (native 64-bit) in the user-agent string.

    if (navigator.userAgent.indexOf("WOW64") != -1 || 
        navigator.userAgent.indexOf("Win64") != -1 ){
       alert("This is a 64 bit OS");
    } else {
       alert("Not a 64 bit OS");


I’ve done some tests. Here are the results, hope it helps:

64 bit MacOS + 64 bit Safari or 32 bit Chrome:

32 bit windows + safari:

64 bit Windows + 64 bit IE:

64 bit Windows + 32 bit IE:

64 bit Windows + 32 Firefox (or Chrome):

32 bit linux mint (i686) + firefox:
window.navigator.platform=Linux i686

64 bit Ubuntu (x86_64) + 32 bit Chrome:
window.navigator.platform=Linux i686

64 bit Ubuntu + 64 bit Epiphany:
window.navigator.platform=Linux x86_64

So far i’ve used this code:

deployJava.isWin64OS = function() {
    return navigator.userAgent.indexOf('WOW64')>-1 || window.navigator.platform=='Win64';


Analysing around 14000 unique user-agents (from here), I’ve come up with the following strings to look for:

  • x86_64
  • x86-64
  • Win64
  • x64; (Mind the semicolon! Without it you will have false-positives.)
  • amd64
  • AMD64
  • WOW64
  • x64_64

Additionally, although they have different instruction sets and are not compatible with Intel x86_64, you may want to detect the following:

  • ia64
  • sparc64
  • ppc64
  • IRIX64

Beware though, don’t just look for anything containing “64” or even “x64”. Chrome’s build numbers, spiders/bots, libraries, .NET versions, resolutions, etc. may also contain the string “x64” while still being a 32-bits (or other) OS.

Note that you can search for all those strings case-insensitively.

I have not been able to find anything on ARM. Perhaps someone else? Please edit, it is a community wiki.


You can check the window.navigator.platform and the window.navigator.cpuClass.

I’m not sure your situation, but I would consider just doing what most other sites do and let the user choose which download they get. They could be downloading it for another machine, to put on a flash device, or just may simply want the 32-bit version to run on their 64-bit box. Whatever reason, I would rather have the choice.


The most reliable solution would be to create a 32bit loader application that detects the architecture and then downloads and installs the appropriate version of your application.

I’ve checked the other two answers from RC and Pino. They both do not work because of the same problem as you suggest – 32-bit IE on 64-bit Windows will wrongly identify the platform as 32-bit. As most people run 32-bit IE on 64-bit Windows (many plugins e.g. Flash are not available in 64-bit), there will be a lot of innacurate identifications



Not with 100% certainty as you say the browser could be a 32bit version while the OS a 64bit.

To detect the browser, please try the following code:

<script language=javascript>   
  document.write("CPU :"+window.navigator.cpuClass);   

CPU : ia64

For IE.


Commercial Product : https://www.cyscape.com/showbrow.aspx


For 64-bit Windows with 64-bit IE window.navigator.platform will be “Win64” and window.navigator.cpuClass will be “x64”.

For 64-bit Windows with 32-bit IE, window.navigator.platform will be “Win32” and window.navigator.cpuClass will be “x86”.

For 32-bit Windows, window.navigator.platform will be “Win32” and window.navigator.cpuClass will be undefined (I think).

Source: I made an app that uses JavaScript to determine if someone is using a 32 bit or 64 bit processor. You can see the code here on GitHub.


I resumed the results of the nice search above into these JS functions. Hope they can help everybody here to catch up a quick response to their needs (and, as well, to mine too !)

function get_bits_system_architecture()
    var _to_check = [] ;
    if ( window.navigator.cpuClass ) _to_check.push( ( window.navigator.cpuClass + "" ).toLowerCase() ) ;
    if ( window.navigator.platform ) _to_check.push( ( window.navigator.platform + "" ).toLowerCase() ) ;
    if ( navigator.userAgent ) _to_check.push( ( navigator.userAgent + "" ).toLowerCase() ) ;

    var _64bits_signatures = [ "x86_64", "x86-64", "Win64", "x64;", "amd64", "AMD64", "WOW64", "x64_64", "ia64", "sparc64", "ppc64", "IRIX64" ] ;
    var _bits = 32, _i, _c ;
    for( var _c = 0 ; _c < _to_check.length ; _c++ )
        for( _i = 0 ; _i < _64bits_signatures.length ; _i++ )
            if ( _to_check[_c].indexOf( _64bits_signatures[_i].toLowerCase() ) != -1 )
               _bits = 64 ;
               break outer_loop;
    return _bits ; 

function is_32bits_architecture() { return get_bits_system_architecture() == 32 ? 1 : 0 ; }
function is_64bits_architecture() { return get_bits_system_architecture() == 64 ? 1 : 0 ; }

Test it:

document.write( "Which is my current bits system architecture ? " + get_bits_system_architecture() + "<br>" );

document.write( "Is it 32 bits ? " + ( is_32bits_architecture() ? "YES" : "NO" ) + "<br>" );

document.write( "Is it 64 bits ? " + ( is_64bits_architecture() ? "YES" : "NO" ) );

Thanks to everyone!


I used following code:

var is32BitBrowser = true;
if( window.navigator.cpuClass != null && window.navigator.cpuClass.toLowerCase() == "x64" )
   is32BitBrowser = false;
if( window.navigator.platform.toLowerCase() == "win64" )
   is32BitBrowser = false;

It worked everywhere expect Mac computers. And unfortunately seems that it’s not possible to get that information via JavaScript :(. However one more trick could be done there. Because Adobe didn’t support flash player on x64 browsers, you can just try to detect it. If detection is successful, than it is definitely 32 bit browser, if no, than it’s 32 bit browser without flash plugin or it’s 64 bit browser. Because penetration rate of Flash player is quite huge(see http://www.adobe.com/products/player_census/flashplayer/version_penetration.html), this should be good enough to at least detect x32 browser under Mac.


64-bit IE on 64-bit Windows for any Internet Explorer browser

if (navigator.userAgent.indexOf("MSIE") != -1 && navigator.userAgent.indexOf("Win64") != -1 && navigator.userAgent.indexOf("x64") != -1){

   alert("This is 64 bit browser");

else {

   alert("Not 64 bit browser");



Both window.navigator.cpuClass and window.navigator.platform return the browser platform. Not the system platform. So if you are running a 32-bit browser on a 64-bit system then both varibales would return 32-bit. Which would be incorrect.


I’ve found this old question and thought updating with a recent open source library I found: https://github.com/faisalman/ua-parser-js

According to the docs, the method getCPU() returns { architecture: '' }, with the following possible values: 68k, amd64, arm, arm64, avr, ia32, ia64, irix, irix64, mips, mips64, pa-risc, ppc, sparc, sparc64.

Leave a Reply

Your email address will not be published. Required fields are marked *