AST stands for abstract syntax tree, a tree of nodes that represents the grammatical structure of source code without the punctuation and whitespace. A parser builds it from text, and tools such as compilers, linters, formatters, bundlers and transpilers read and change it. For JavaScript, the community format is ESTree, whose steering committee has members from ESLint, Acorn and Babel.
A parser first splits code into tokens, then arranges the tokens into a tree that follows the language grammar. Each node has a type, such as an assignment, a function call or a number, and children for its parts. The tree is "abstract" because it drops details that do not change meaning: parentheses, semicolons and most whitespace. Operator precedence is already resolved by the tree shape.
Node names are not universal. Python's ast module, ESTree for JavaScript and other languages each define their own node types, so a tool written for one tree format will not read another. Trees also change between language versions as new syntax is added.
This Python run parses a one-line assignment and prints the tree. Note that the multiplication sits deeper than the addition, which is how precedence appears in a tree:
import ast
t = ast.parse("total = price * 2 + 1")
print(ast.dump(t, indent=2))
Module(
body=[
Assign(
targets=[
Name(id='total', ctx=Store())],
value=BinOp(
left=BinOp(
left=Name(id='price', ctx=Load()),
op=Mult(),
right=Constant(value=2)),
op=Add(),
right=Constant(value=1)))],
type_ignores=[])
That output came from Python 3.11.15. The indent option of ast.dump was added in Python 3.9. From Python 3.13, ast.dump hides empty lists by default, so the type_ignores=[] line does not appear.
A parse tree, also called a concrete syntax tree, keeps every token the grammar matched, including parentheses and punctuation. An AST keeps only the structure that matters for meaning. Parse trees are larger and mirror the grammar exactly, while an AST is smaller and easier to analyze. Some formatters need extra comment and whitespace data attached to the AST so they can print code the way it was written.
Linters such as ESLint find bugs by matching tree patterns. Formatters re-print code from the tree. Transpilers like Babel rewrite newer syntax into older syntax. Bundlers use the tree to find imports and remove unused code, and code-search and refactoring tools use it to find a function call without confusing it with the same text inside a string.