Child pages
  • JavaScript Code Model
Skip to end of metadata
Go to start of metadata



Please see this blog post.

JavaScript Code Model project (JSCM for short) provides a Java API for programmatic creation and manipulation of JavaScript source code.

JSCM models grammatical structure of JavaScript (accoring to the ECMAScript specification) in Java classes. This allows building JavaScript code from Java programmatically.

Once object model of the JavaScript program is built, it can be formatted and printed out into a writer. The result is well-formatted (with indentation, line breaks etc.) and is almost guaranteed to be in correct JavaScript syntax.

Getting JavaScript Code Model

Maven Artifacts

If you're using Apache Maven (or compatible build tools), please use the following dependency:

JSCM is distributed via the Central Maven repository.

SourceForge-Hosted Files

You can also download JSCM files from SourceForge:

JSCM does not have any runtime dependencies. You basically only need one JAR file (js-codemodel-version.jar).

Using JavaScript Code Model

Usage is rather straightforward. Here's a small example:

This produces the following JavaScript code:


JSCM model JavaScript grammar with high precision. However there are certain things we've not implemented at the moment.

  • Comments are not supported at the moment.
  • Regular expressions are not supported at the moment.
  • Identifier names are not checked for correctness.
  • It is possible to create a construct like:

Further Information and Links


Maven Site:

JSCM is hosted and developed on



Mailing list:

  • No labels