AST Query Playground

AST Query Playground

Source and structural query

JavaScript ES2020 only · up to 16000 characters · 2500 nodes · 8 query terms

Examples: FunctionDeclaration >> ReturnStatement · BlockStatement > ReturnStatement · Literal[value="hello"] · LineComment. > is a direct child; >> is any descendant.

No source execution or upload. TypeScript/JSX and full CSS selector syntax are not supported.

Syntax tree result

Edit an example or source, then run the analysis.

Comments & questions

AST Query Playground

A regular expression finds character sequences; this tool parses ES2020 syntax into ESTree nodes. Query ancestor and descendant structure, inspect source locations and download a selected node as JSON. Source code is never evaluated. Comments are displayed separately as lexical items, not represented as syntax nodes.

Key features

  • Parse real ESTree syntax with Acorn in a fixed ES2020 Script/Module profile
  • Match node type and one name/value/operator/kind/callee attribute with > direct-child or >> descendant relations
  • Distinguish nested functions, identifiers, string Literals and separately captured LineComment/BlockComment items
  • Highlight exact source ranges and navigate a bounded node tree
  • Copy or download full selected ESTree node JSON with precise syntax/query error positions

How to use

  1. Choose the nested-function, module or comment example, or paste a local JavaScript file.
  2. Select the Script or Module parsing goal and keep source within the ES2020 profile.
  3. Enter a query such as FunctionDeclaration >> ReturnStatement or Literal[value="hello"].
  4. Run analysis; select a match or tree item to inspect its source range.
  5. Copy or download selected node JSON and refine the query as needed.

Use cases

  • Tell nested returns from a function’s outer return
  • Tell whether a word is a comment, string or identifier
  • Locate descendants of a named function declaration
  • Inspect node relationships beneath a module export
  • Study concrete ESTree node JSON during code review or parser learning

Frequently asked questions

Which language versions are supported?

JavaScript ES2020 Script and Module only. TypeScript type syntax, JSX, features newer than ES2020, CSS and Python are not parsed. Invalid code for the selected goal gets an error and source position.

What query syntax is supported?

Use a node type or *, optionally with one [name=value], [value="text"], [operator=+], [kind=const] or [callee=log] filter. > means direct child, >> means descendant at any depth. Multiple filters, OR, full CSS selector syntax and regex queries are unsupported.

Are comments AST nodes?

No. ECMAScript comments are lexical trivia, not syntax tree nodes. Acorn captures them through a comment callback; the explorer places them under the smallest enclosing node only for navigation. Query them as LineComment or BlockComment.

Is the code executed or sent to a server?

No. Parsing and matching stay inside the browser. The tool never evals, imports or invokes user code and never posts it to a server. Only an explicit download saves the selected node.

Why are some results hidden?

Source is capped at 16,000 characters, the AST at 2,500 nodes, and queries at 240 characters and eight terms. The screen previews the first 180 tree items and 80 matches while showing the total match count. Node-limit failures reject the entire result.

Privacy

Pasted or selected source is parsed only in your browser. There is no eval, code execution or server upload. Exported node JSON may include source strings; review it before sharing.

References

Related Tools

Regex TesterJavaScript MinifierJSON FormatterWasm Module InspectorHreflang Matrix CheckerContainer Build GraphDependency Graph ExplorerSemver Range LabCron Schedule AuditorPatch Review WorkbenchSource Map ExplorerLocalization Catalog AuditorStructured Data ReviewerHTTP Archive AnalyzerWebhook Signature LabProtobuf Schema WorkbenchGraphQL Schema LabAvro Schema EvolutionLocal SQL WorkbenchSchema Form BuilderMesh Repair WorkbenchPipe Network LabRobot Arm Kinematics LabThermal Network LabBeam Response LabGear Train DesignerTolerance Stackup LabSensor Calibration FitPCB Stackup PlannerDigital Filter DesignerNetwork Reachability MapSun Shadow MapGPS Error SimulatorDigital Logic SimulatorAnalog Circuit LabMechanism Linkage LabAnalysis Mesh GeneratorOpenAPI Contract InspectorDatabase Migration PlannerDimensional Equation CheckerTruss Force LabBoolean Minimization LabControl Response LabQueueing Simulation LabGeofence Event SimulatorCoordinate Reference LabSurvey Traverse LabRaster Classification LabChoropleth Design LabMap Print ComposerRaster Reprojection LabElevation Contour MakerTerrain Viewshed LabWatershed DelineatorMap Tile PackagerText File Encoding WorkbenchFilesystem Portability AuditorSBOM License ExplorerFile Signature Auditornpm Lockfile Conflict ResolverSource Secret AuditorOffline Web Package BuilderCertificate Chain InspectorTorrent Metainfo InspectorChunked File PackagerEncrypted File VaultDuplicate File FinderArchive WorkbenchDesign Token ManagerSpacing Token DesignerResponsive Type SystemPackaging Dieline DesignerSVG Icon Sprite PackerFlex Layout PlaygroundCSS Grid PlaygroundRegex Equivalence LabMarkdown Repository AuditorLog Template MinerResponsive Layout AuditorEmail Template PreviewInternal Link GraphState Machine TesterPetri Net SimulatorGit History VisualizerCurl Request WorkbenchBinary Protocol DesignerHex File EditorBinary Patch WorkbenchFile Signature WorkbenchAPI Mock SandboxSchema Column MapperEvent Log SessionizerER Diagram DesignerTime Series Gap AuditorStratified Data SplitterData Lineage DesignerDecision Tree LabData Anonymization WorkbenchData Expectation RunnerJSON Schema ValidatorBasket Pattern AnalyzerRobots Policy TesterSEO HTML AuditorAccessibility Structure AuditorSyndication Feed WorkbenchIndexNow Payload BuilderCrawl Log AnalyzerCSP Policy WorkbenchSearch Performance AnalyzerCSV Formula Risk AuditorCORS Response SimulatorCache Header LabCookie Policy InspectorWeb Vitals Trace LabSitemap Health AuditorBatch File RenamerFile Manifest VerifierFolder Space MapFolder Difference ReviewerRoute Order OptimizerGeoJSON Map EditorPolygon Overlay LabCartographic Label PlacerSpatial Table JoinGeoJSON Topology AuditorGPX Track AnalyzerTrack Privacy RedactorCSV Table JoinCSV Pivot WorkbenchScientific Data ProfilerTabular Cleaning WorkbenchRecord ReconciliationData Dictionary BuilderCanonical Graph AuditorRedirect Plan TesterHTTP response and ping reference testBrowser and System InformationJSON ↔ YAML ConverterXML ↔ JSON ConverterHTML FormatterMock Data Generator.gitignore GeneratorLicense GeneratorUser-Agent ParserPassword Strength CheckerCode to ImageXML FormatterHTTP Status Code LookupMIME Type LookupJS & SQL String EscapeCSS Box Shadow GeneratorCSS Gradient GeneratorIndent ConverterNumber Base ConverterUnicode Escape ConverterUnicode InspectorJSON Structure DiffMarkdown Table GeneratorBase64 EncoderURL EncoderSQL FormatterCron Expression GeneratorUUID GeneratorHash GeneratorTimestamp ConverterJWT DecoderHTML Entity ConverterMarkdown PreviewCSS MinifierMeta Tag GeneratorJSON ↔ CSVCase ConverterImage to Base64
Explore all Dev Tools tools →Image/Media →Text/Convert →Life/Fun →