JavaScript Inspector
Paste JavaScript or open a .js file. The page reads it with acorn, the parser used by many JavaScript tools, and shows what the code imports and exports, its functions, classes and top-level variables, and its syntax tree (AST), which you can open node by node or save as JSON. The code is never run.
Inspect JavaScript
Outline
Syntax tree
Open a node to see the nodes inside it.
How to inspect JavaScript
- Paste the code into the box, or press Or open a JavaScript file.
- Leave Read as on Find out (a module first, then a classic script), or choose one.
- Read the outline: imports (import, import() and require()), exports, functions with their parameters, classes with their members, and top-level variables.
- Open Syntax tree to walk the AST; Select it in the code marks the code of a node. Press AST as JSON or Tokens to copy or download them.
What the syntax tree is
A parser turns code into a tree of nodes, such as a VariableDeclaration that holds a VariableDeclarator, whose init is a CallExpression. The node names follow ESTree, the shared format of JavaScript tools (ESLint, Babel, Prettier and bundlers read the same shapes). Each node has its place in the code (start and end characters, and lines and columns when you tick Positions).
Worked example
In the sample, the outline lists 2 imports (./cart.js and a dynamic import() of ./pay.js), 2 exports (total and Cart), 4 functions (total, the arrow function inside reduce, fmt and pay), and the class Cart with the members #items, add() and get size. The expression a + b * c becomes BinaryExpression + with BinaryExpression * on its right, because * binds tighter.
Limits you should know
- JavaScript up to ES2025 is read; TypeScript and JSX are not (remove their types or tags first).
- The outline reads the code as written: names built at run time, such as require(variable), are shown as (computed).