Start a project

Tool 127 of 194 · JavaScript

JavaScript AST Explorer

See how JavaScript parses: browse the syntax tree and jump between nodes and the code they cover.

JavaScript AST Explorer

JavaScript

Selected node:


  

Path:

Syntax tree (ESTree)

Selected node

FieldValue

Node types

TypeCount

AST as JSON

ESTree JSON

01

What it does

Parses JavaScript with Acorn into an ESTree syntax tree you can browse, linked both ways to the source, with node fields, type counts and JSON.

  • Parses modern JavaScript with Acorn: classes and private fields, optional chaining, BigInt, top-level await and more
  • Module or script, and any ECMAScript version from ES3 to the latest
  • Click in the code to find the deepest node there; click a node to highlight its code
  • Each node's fields, path from the root and line and column range

02

Private by design

Everything happens in your browser. Nothing you type, paste or upload is sent anywhere, and it keeps working offline once the page has loaded.

03

What you get

A browsable ESTree tree, the selected node's code and fields, node type counts and JSON, with a Copy and a Download button on every result.

  • JavaScript
  • Parsing
  • Tooling

Why it matters

Linters, bundlers, codemods and minifiers all work on a syntax tree rather than on text. Writing an ESLint rule or a Babel or jscodeshift transform starts with knowing what that tree looks like for the code you want to match: which node types, which fields, and how they nest.

This explorer parses your code with Acorn, the parser behind webpack, Rollup and ESLint's espree, and shows the ESTree it produces. Click in the code to jump to the node under the cursor, or open the tree and click a node to highlight the code it covers. The output was checked node for node against meriyah, an independent ESTree parser, on more than 200 real files.

How to use it

  1. Paste your JavaScript.
  2. Choose module or script and the ECMAScript version.
  3. Click code or open tree nodes to explore.
  4. Download the JSON if you need it.

FAQ

What is an AST?

An abstract syntax tree: the structure of your code as nested nodes, such as a function declaration containing a block containing statements.

What is ESTree?

The common format for JavaScript syntax trees, used by Acorn, ESLint, Prettier, Rollup and many other tools.

Does it support TypeScript or JSX?

No. It parses standard JavaScript. Strip types and JSX first, or use a parser that supports them.

Why do I get a SyntaxError?

The code isn't valid for the chosen mode and version. import and export need module mode, and newer syntax needs a later version.

Credits and licences

Parses with Acorn 8.19.0 (MIT License, Marijn Haverbeke and contributors; licence text).

Work with me

Want a site that gets these right?

I build fast, accessible websites and web apps that pass these checks from day one. Tell me about your project and I'll reply personally with honest next steps.

All developer tools · Back to leej.uk