Code & Media

AST Explorer

Parse JavaScript, TypeScript, or JSX and explore the resulting syntax tree.

  • Draft kept in this tabYour draft is kept in this tab's session storage and cleared when the tab closes.
  • Runs in your browserProcessing happens in this page. No application server receives your input.
Load sample

Source code input

Abstract syntax tree output

Spine

No AST nodes to display.

AST JSON

Parse details

Language
TS
Input size
0 B
Nodes
0
Ranges
UTF-8 byte offsets + UTF-16 display
Execution
Worker (codegen)

About JavaScript, TypeScript, JSX, JSON & CSS AST Exploration

Parses JavaScript, TypeScript, JSX/TSX, strict JSON, or CSS source text into an abstract syntax tree in the background without ever evaluating the source.

Strict Grammar & Safe Inert Parsing (FR-CODE-1)

Source text is lexed and parsed purely as data inside codegen.worker.ts. No code, script tags, or expressions are ever executed. JSON mode enforces the strict RFC 8259 JSON grammar so trailing commas are reported as ParseFailed rather than silently accepted.

UTF-8 Byte Offsets & UTF-16 Display Mapping (GAP-045)

When range tracking is enabled, every AST node records both its UTF-8 byte span (range: [startByte, endByte]) and its UTF-16 code-unit span (utf16Range: [startUnit, endUnit]) so multi-byte Unicode characters map accurately between byte-oriented parsers and JavaScript string indices.

Resource & Complexity Caps

Inputs are capped at 2 MiB of UTF-8 source text (InputTooLarge), 200,000 AST nodes (NodeCapExceeded), and 512 levels of nesting depth (DepthExceeded). Syntax errors return ParseFailed with 1-based line and column diagnostics rather than falling back to a looser parser.

Worked Example

Input source:

const a = 1;

Expected AST spine summary:

VariableStatement > VariableDeclarationList > VariableDeclaration(a = 1)

Scope: this covers the page itself. Your browser, operating system, clipboard, downloads, extensions, and crash recovery may keep copies, and a compromised site origin would not be protected.