JavaScript Parser

Input

                                
Output

                                
Properties
Returns an Abstract Syntax Tree for valid JavaScript code.

Location Info:
Range Info:
Include Tokens Array:
Include Comments Array:
Report Errors and Try to Continue:
Parse Restart {{ copied ? 'Copied!' : 'Copy AST' }} Download AST

JavaScript Parser: Advanced JavaScript Parser and AST Generator

Why Parse JavaScript into an AST?

When web browsers or JavaScript engines (like V8) execute your code, they don't read raw text. Instead, they parse the raw source code into an Abstract Syntax Tree (AST)—a structured, deeply nested JSON representation of your code's syntax and logic.

For modern frontend developers, understanding and manipulating the AST is a superpower. If you are building custom ESLint rules, creating Babel plugins to transpile modern ES6+ syntax, or developing custom code formatters and bundlers, you must know exactly how your JavaScript code translates into AST nodes (such as VariableDeclarator, ArrowFunctionExpression, or CallExpression).

Our online JavaScript Parser instantly converts your raw JS code into a strictly formatted, human-readable JSON Abstract Syntax Tree, strictly adhering to the standard ESTree specification.

Engineered for Source Code Privacy: 100% Client-Side Parsing

As software engineers, we understand that pasting proprietary source code or algorithms into random online tools violates strict corporate security policies.

We built this JS Parser with your code's absolute privacy in mind.

  • Zero Server Uploads: We never transmit, save, or log your JavaScript code or the generated JSON tree.

  • Absolute Local Execution: The lexical analysis and tokenization run completely offline within your web browser's local sandbox memory.

  • Instant Compilation: Because no data is sent to a remote backend API, the parsing and tree generation happen instantaneously.

How to Generate an AST from JavaScript Online

Transforming your source code into a detailed syntax tree is frictionless:

  1. Paste Your JavaScript: Enter your raw JS code (supporting modern ES6/ES7+ syntax, arrow functions, async/await, and classes) into the left editor panel.

  2. Instant Lexical Parsing: Our client-side parsing engine immediately tokenizes the code and builds the hierarchical structure.

  3. Explore the AST: The tool outputs a detailed, collapsible JSON tree on the right. You can inspect specific AST Nodes, properties, and line/column locations to precisely identify how the engine interprets your code.

Frequently Asked Questions (FAQ)

  • Q: What specification does this JavaScript parser use?

    A: Our parser outputs the AST according to the widely adopted ESTree specification. This is the exact same underlying standard utilized by popular developer tools like ESLint, Rollup, and Babel, ensuring the JSON structure you see here matches what your plugins will interact with in a real-world codebase.

  • Q: Does the parser support modern ECMAScript (ES6+) syntax?

    A: Yes. The parser is equipped to handle modern JavaScript syntax, including template literals, destructuring assignments, spread operators, async/await, and modern class declarations.

  • Q: Why do I get a "SyntaxError" when parsing?

    A: A parser requires strictly valid JavaScript to generate a complete Abstract Syntax Tree. If you miss a closing bracket }, a parenthesis ), or use invalid syntax, the parser cannot build the tree and will instantly throw a parsing error, highlighting the exact line and column where the compilation failed.

  • Q: Can I reverse the JSON AST back into JavaScript code?

    A: This specific tool acts strictly as a parser (Code-to-AST). To convert an altered AST JSON object back into raw JavaScript string, you would need a code generator tool (such as Babel Generator or Escodegen) in your local development environment.

Featured Tools

Featured tools that you might find useful.

Popular Tools

List of popular tools that users love and frequently use.

New Tools

The latest tools added to our collection, designed for you.

Topics

The tools grouped by topics to quickly find what you need.
SRT To TXT Converter can transform subtitle files in .srt format into plain text (.txt) files. Simply paste the SRT subtitle content into the provided text box or select an SRT file, and it will automatically extract the textual content from the subtitles. Afterwards, you can copy the text or download it as a .txt file for further use.

SRT To TXT Converter

SRT To TXT Converter can transform subtitle files in .srt format into plain text (.txt) files. Simply paste the SRT subtitle content into the provided text box or select an SRT file, and it will automatically extract the textual content from the subtitles. Afterwards, you can copy the text or download it as a .txt file for further use.
SRT To ASS Converter enables seamless conversion between .srt and .ass subtitle file formats. Simply select either an .srt or .ass formatted file, and the converter will automatically transform it into the another format.

SRT To ASS Converter

SRT To ASS Converter enables seamless conversion between .srt and .ass subtitle file formats. Simply select either an .srt or .ass formatted file, and the converter will automatically transform it into the another format.
SRT Editor is an online subtitle editor for SubRip Subtitle (SRT) file, it  allows you to batch-adjust the playback speed and timing offset of subtitles, and also provides the ability to individually adjust the order, timecodes, and text of each subtitle segment.

SRT Editor

SRT Editor is an online subtitle editor for SubRip Subtitle (SRT) file, it allows you to batch-adjust the playback speed and timing offset of subtitles, and also provides the ability to individually adjust the order, timecodes, and text of each subtitle segment.
SRT To VTT Converter enables seamless conversion between SubRip Subtitle(.srt) and Web Video Text Tracks (WebVTT)(.vtt) subtitle file formats. Simply select either an .srt or .vtt formatted file, and the converter will automatically transform it into the another format.

SRT To VTT Converter

SRT To VTT Converter enables seamless conversion between SubRip Subtitle(.srt) and Web Video Text Tracks (WebVTT)(.vtt) subtitle file formats. Simply select either an .srt or .vtt formatted file, and the converter will automatically transform it into the another format.