Skip to content
SPECIFICTION
Get listed

ast-grep

ast-grep.github.io

Free plan WebWindowsmacOSLinuxAPIBrowser extension
Visit ast-grep.github.io
Spec score 9.1 #1 of 42 in Code Search Tools

What it is

ast-grep is a free, open-source tool for structural code search, linting, and rewriting. It matches patterns against syntax-tree nodes, helping developers locate and change code across a codebase rather than searching plain text. Its CLI can preview and apply rewrites interactively, and scan configurable YAML rules with error, warning, info, or hint severity. Rules can combine pattern, kind, regex, relational, and composite conditions, and CLI commands help create and snapshot-test them. The project says it supports more than 20 languages and can load custom languages. JavaScript and WebAssembly APIs allow programmatic syntax-tree work; a browser playground offers a way to try patterns without local installation. Editor options include a VS Code extension and language-server setups, including for Vim and Neovim. The tool is free, has a web interface, and is distributed through package managers or built from source. Its FAQ notes that some advanced static-analysis information is unsupported, and one rule cannot target multiple languages at once.

Spec sheet

What it does
ast-grep is a fast, polyglot tool for structural code search, linting, and large-scale rewriting.Read 4 Oct 2026 · ast-grep.github.io
Purpose
ast-grep is a fast, polyglot tool for structural code search, linting, and rewriting at scale.Read 4 Oct 2026 · ast-grep.github.io
Integrations
The documentation describes editor integrations, including a VS Code extension and language server support for editors such as Vim and Neovim.Read 4 Oct 2026 · ast-grep.github.io
Support
The project directs users with questions or issues to GitHub or Discord and also points to Stack Overflow and Reddit.Read 4 Oct 2026 · ast-grep.github.io
APIs
ast-grep provides a JavaScript API for programmatically inspecting and changing syntax trees, plus a WebAssembly API for browsers and other WASM environments.Read 4 Oct 2026 · ast-grep.github.io
Code rewriting
The CLI can interactively preview and apply rewrites to matching code.Read 4 Oct 2026 · ast-grep.github.io
Custom rules
Rules are written in YAML and can combine pattern, kind, regex, relational, and composite matching conditions.Read 4 Oct 2026 · ast-grep.github.io
Distribution
The CLI is distributed through npm, Cargo, Homebrew, MacPorts, Nix, and pip, and can also be built from source.Read 4 Oct 2026 · ast-grep.github.io
Install methods
The CLI is distributed through npm, Cargo, Homebrew, and MacPorts, with source builds also available.Read 4 Oct 2026 · ast-grep.github.io
Language support
The site says ast-grep supports 20+ programming languages and can load custom languages.Read 4 Oct 2026 · ast-grep.github.io
Languages
The project says it supports 20+ languages and allows custom languages to be loaded.Read 4 Oct 2026 · ast-grep.github.io
Limits
The FAQ says ast-grep does not currently support some advanced static analysis information.Read 4 Oct 2026 · ast-grep.github.io
Lint rules
Users can define custom lint rules with AST patterns and receive error reporting.Read 4 Oct 2026 · ast-grep.github.io
Linting
The scan command runs configurable AST pattern rules and supports severity levels including error, warning, info, and hint.Read 4 Oct 2026 · ast-grep.github.io
LSP capabilities
The language server publishes diagnostics and supports diagnostic code actions; linting diagnostics require an sgconfig.yml project file.Read 4 Oct 2026 · ast-grep.github.io
Notable limitation
A rule cannot target multiple languages at once; the FAQ recommends a superset language with languageGlobs or separate rules for each language.Read 4 Oct 2026 · ast-grep.github.io
Other editor integrations
The editor guide documents setups for Neovim and Emacs, plus community integrations for coc.nvim, Telescope, and grug-far.nvim.Read 4 Oct 2026 · ast-grep.github.io
Pattern search
It matches code patterns against syntax tree nodes rather than searching source text.Read 4 Oct 2026 · ast-grep.github.io
Performance
The site describes search and replace across thousands of source files as powered by parallel Rust.Read 4 Oct 2026 · ast-grep.github.io
Programmatic API
The JavaScript API lets programs inspect and change syntax trees using JavaScript.Read 4 Oct 2026 · ast-grep.github.io
Publisher
The site credits Herrington Darkholme in its copyright notice.Read 4 Oct 2026 · ast-grep.github.io
Rule testing
The CLI includes commands to create and test rules, with snapshot-based test options.Read 4 Oct 2026 · ast-grep.github.io
Search and rewrite
It uses code patterns and abstract syntax trees to find and modify code across many files, with an interactive rewrite mode.Read 4 Oct 2026 · ast-grep.github.io
Security use
The example catalog includes rules for detecting security issues, such as a Go JSON tag vulnerability and C/C++ format string risks.Read 4 Oct 2026 · ast-grep.github.io
Support channels
The site links to Discord, Stack Overflow, and Reddit community channels.Read 4 Oct 2026 · ast-grep.github.io
VS Code
The official VS Code extension provides a UI for the CLI and a client for the ast-grep language server.Read 4 Oct 2026 · ast-grep.github.io
Web playground
The online playground lets users try patterns and rewrite rules without installing ast-grep locally.Read 4 Oct 2026 · ast-grep.github.io

Plans and prices

ast-grep Free Pricing not stated on the opened official pages Read 4 Oct 2026 · ast-grep.github.io

Every ast-grep plan and price →

Strong points and limits

Strong points

  • Searches and rewrites syntax-tree patterns across codebases
  • Supports 20+ languages and custom language loading
  • YAML rules can combine several matching conditions
  • Includes JavaScript and WebAssembly APIs
  • Free and open source

Limits

  • Some advanced static-analysis information is unsupported
  • A single rule cannot target multiple languages at once

Who it suits

It suits developers who need pattern-based code search, lint rules, or large-scale rewrites across supported languages. Editor users can work through the VS Code extension or documented language-server integrations.

ast-grep in depth

Read the full write-up

ast-grep is a free, open-source tool for developers who need to find and change code by structure rather than by text. It suits teams building repeatable code checks or refactors across a codebase. Its strongest case is syntax-aware work across many languages; it is not a replacement for advanced static analysis.

Overview

Because ast-grep matches patterns against syntax-tree nodes, it can target code forms without depending on an exact textual match. That makes it useful when a broad text search would catch irrelevant code or miss formatting variations. The CLI supports previewing and applying rewrites interactively, and the project describes parallel Rust processing for searches and replacements across thousands of source files.

Structural matching gives developers control over what a rule targets, but it does not reveal every property of program behavior. The FAQ says some advanced static-analysis information is not supported, so teams needing deeper analysis should look elsewhere or use another tool alongside it.

Key features

Search, rewrite, and lint

The scan command runs configurable rules against syntax patterns and reports severities including error, warning, info, and hint. This makes ast-grep useful for recurring code-shape checks as well as one-off searches. Interactive rewrite preview is a sensible safeguard for broad changes, though the rules still need to express the intended code structure accurately.

Custom rules and testing

Rules are written in YAML and can combine pattern, kind, regex, relational, and composite conditions. CLI commands help create and test rules, including snapshot-based testing. That combination suits teams that want reusable checks they can validate before applying across a codebase; it asks more of users than a ready-made search box because they must define the rule logic.

Languages and integrations

The project says it supports more than 20 languages and can load custom languages. A rule cannot target multiple languages at once, however; users must use a superset language with languageGlobs or maintain separate rules. That is a meaningful cost for teams seeking one shared rule set across heterogeneous repositories.

The VS Code extension provides a UI for the CLI and a client for the language server. The server publishes diagnostics and diagnostic code actions, while lint diagnostics require an sgconfig.yml project file. Documentation also covers Neovim and Emacs setups and community integrations for coc.nvim, Telescope, and grug-far.nvim.

APIs and playground

The JavaScript API lets programs inspect and change syntax trees, while the WebAssembly API supports browsers and other WASM environments. An online playground lets users try patterns and rewrite rules without installing the tool locally. These options make ast-grep useful beyond terminal workflows, though the core value remains its rule-based structural matching.

Pricing

ast-grep is free and open source, with a free plan priced at free. There is no free trial because the tool is already free. The plan is a practical fit for individual developers and teams that can run and manage the software themselves; there are no paid plan tiers or stated seat caps to weigh against a subscription.

The CLI is distributed through npm, Cargo, Homebrew, MacPorts, Nix, and pip, and can also be built from source. The deployment model is self-hosted, so users should expect to manage their own environment rather than rely on a hosted service.

Platforms

ast-grep supports Linux, macOS, and Windows, alongside API, extension, and web access. Its CLI can be installed through several package managers, and editor integrations connect it to IDE and language-server workflows. The browser playground and WebAssembly API offer ways to work without a local CLI installation.

Who it's for

ast-grep is best for developers who need repeatable structural searches, lint rules, or large-scale code rewrites and are comfortable working with syntax patterns. It can also suit teams that want to encode code-shape checks in rules and test those rules before applying them broadly. Users who need advanced static-analysis information, or a single rule that spans several languages, should consider another approach.

Pros and cons

Structural matching: Patterns target syntax-tree nodes, which is more selective than matching source text when code formatting or surrounding structure matters.

Reusable, testable rules: YAML conditions and CLI rule-testing commands help teams maintain repeatable checks instead of relying only on ad hoc searches.

Broad access: CLI, editor integrations, JavaScript and WebAssembly APIs, and a browser playground accommodate different workflows.

Language-specific rule work: A rule cannot target multiple languages at once, which adds maintenance for mixed-language codebases.

Analysis boundary: Some advanced static-analysis information is unsupported, limiting its fit for checks that depend on deeper program analysis.

Alternatives

Code Search is worth considering when repository-wide full-text search, find-and-replace, and SCIP code intelligence matter more than ast-grep's syntax-pattern rules; its Community plan is free with unlimited users and includes a CLI and MCP server.

OpenGrok is another free, open-source option for readers comparing code search tools. Sourcebot offers a free Basic plan and a free trial for code search. sqry is a free, local-running open-source option for Linux, macOS, and Windows. Shebe is a free local code-search option. Understand may suit readers seeking a freemium alternative with a paid annual subscription; its listed annual plan is $100,120 a year with a minimum term of 12 months. Code Fundi is a freemium alternative with a Dev plan at $21 a month, including 5,000 Credits/Mo and 10 Private Repo Indexes. Hound is another free code-search option.

For broader comparisons, see Code Search Tools and Code Refactoring Tools.

Verdict

Choose ast-grep if you want a free, self-hosted way to search, lint, and rewrite code by syntax structure, with rules you can test and use from the CLI, editors, or APIs. Its main reason to look elsewhere is equally clear: teams that need advanced static analysis or a single rule across multiple languages will have to choose a different tool or supplement it.

Verdict

ast-grep combines structural search, linting, and rewriting in a free tool with CLI, editor, API, and browser options. Its stated limits matter for users who need advanced static analysis or one rule spanning several languages.

Where Specifiction places it

Alternatives to ast-grepAll alternatives →