ScriptConverter

Convert VBScript to Javascript, in a fraction of the time!, kinda.


Try ScriptConverter

2023-11-27 - AI LLMs can convert code now! :

RIP 2010-08-04 - two comments:


ScriptConverter started as a shortcut for work I often did in 2002-2004.  I was surprised when a few folks expressed interest in making it a community project, which was exciting, but it didn't go far.  As a result, it looked exciting(!), but is little more than a prototype.  One roadblock is that VBScript has many convenience functions built-in (e.g. for Dates), which Javascript does not

I'm glad to know that many have found and benefitted from it.  To those it's helped, you're welcome! 

I think a lot of script beginners have found it too, and were disappointed when their copy/pasted samples didn't run as-is.  To those it's frustrated, my apologies.  Sadly, VBScript is pretty much dead and gone (thanks to web standards, Classic ASP → ASP.net, and WSH → Powershell), and these days what you want is probably already written better in Javascript somewhere. 

What it is:

ScriptConverter performs a basic translation of VBScript code into Javascript code.  It uses Regular Expressions in Javascript to detect the language constructs and map them to the equivalent in Javascript.

Why:

Have you ever inherited a web-project coded with client-side VBScript which had to be upgraded to work in other browsers? Or a project which was coded in a mish-mash of JS & VBS, and which you need to make consistent?  I've had to do both way too many times.  Manually converting is a huge pain, and prone to create syntax mistakes.  After doing the same syntax conversions and thinking for the nth time that a computer should be doing this, I decided it would.  Thus, the ScriptConverter tool was conceived, and way too many hours of painful regular expressions creation were invested to bring it into the world.

How to use it:

  1. Paste in your VBScript (clear the original sample VBScript first).
  2. Click the Convert button.
  3. Copy out your Javascript.
  4. Paste into your editor, and review for any remaining translation work.

limitations

ScriptConverter does not perform a complete translation.  It converts the basic & most-used language constructs -- the first 90% or so of the work.  The remaining 10% you will simply have to convert yourself. 

ScriptConverter has only been tested in IE6.  It may not work correctly in other web browsers.

project docs

If you're interested in the planning & guts: language progress map, converter source, scriptConverter.js, vbs2js_conversions.js, scriptConverter.css

participation

If you want to contribute regular expressions for constructs which aren't covered (or are better than existing ones), they're certainly welcome.  I'd love to open this up to be a community project. 

claimers & disclaimers

ScriptConverter is a work-in-progress, so use it at your own risk.  (And be sure to check your code!)

You may use the tool freely, and copy it to use or play with locally, but please do not mirror it publicly without permission. 

ScriptConverter was created by Rob Eberhardt of Slingshot Solutions.  Send all comments/etc to re@slingfive.com.

credits

There are a few people I gotta thank: Jon Wojtowicz for his contributions and encouragement, and Dean Edwards for his clever js-highlight.htc behavior which I plugged into this.