Skip to content
vic

cjihrig/jsparser

An ECMAScript 5.1 parser, written in JavaScript. The ECMAScript grammar was created using Jison.

cjihrig/jsparser.json
{
"createdAt": "2013-01-02T18:00:58Z",
"defaultBranch": "master",
"description": "An ECMAScript 5.1 parser, written in JavaScript. The ECMAScript grammar was created using Jison.",
"fullName": "cjihrig/jsparser",
"homepage": null,
"language": "JavaScript",
"name": "jsparser",
"pushedAt": "2016-11-27T20:54:04Z",
"stargazersCount": 96,
"topics": [],
"updatedAt": "2025-06-26T17:47:05Z",
"url": "https://github.com/cjihrig/jsparser"
}

An ECMAScript 5.1 parser, written in JavaScript. The ECMAScript grammar was created using Jison.

A blog post describing the project is available here. You can also test the parser online here.

Require the jsparser module, then simply call the parser’s parse() method on a string of JavaScript source code. On success, an AST is returned. On failure, an error is thown.

var parser = require("jsparser");
var source = "console.log('Hello World!');";
var ast;
try {
ast = parser.parse(source);
console.log(ast);
} catch (exception) {
console.log("Parse Error: " + exception.message);
}