A powerful VSCode extension for visualizing and analyzing Abstract Syntax Trees (AST) of Luau/Lua code with interactive type exploration, advanced diffing capabilities, and comprehensive AST node inspection.
- Interactive code editor with live AST updates
- Instant parsing as you type or on-demand
- Side-by-side view of code and corresponding AST
- Perfect for learning how code structures translate to AST nodes
- Visual comparison between two code snippets
- Intelligent change detection (additions, modifications, removals)
- Before/after type annotations show type transformations
- Symbol and color-coded indicators:
- Additions (
+) - Removals (
-) - Modifications (
~) - Containers with changes (
โ)
- Additions (
- Expandable/collapsible tree branches and nodes
- Auto-collapse noisy nodes (trivia, location, position data, etc)
- Clean visual hierarchy for easy navigation
- Type-aware rendering with enhanced annotation display
- Comprehensive type annotations with tooltip details
- Before/after type display in diff mode
- Hover over nodes to show generated/translated code for AST nodes
- Node path display for non-translatable nodes
- Download the
.vsixfile from Releases - Open Editor Command Palette (
Ctrl+Shift+P/Cmd+Shift+P) - Run
Extensions: Install from VSIX... - Select the downloaded
.vsixfile
- Lute [https://github.com/luau-lang/lute] Install via Foreman or Rokit
- Open a Luau/Lua file in VSCode
- Select some code you want to analyze
- Press
Cmd+Shift+A(macOS) orCtrl+Shift+A(Windows/Linux) - Choose your mode:
- Live Editor: Interactive editing with live AST
- Diff Analyzer: Compare two code snippets
| Shortcut | Action |
|---|---|
Cmd+Shift+A / Ctrl+Shift+A |
Open AST Highlight Helper |
- Type or paste code in the editor pane
- Click "Parse AST" for on-demand parsing
- View real-time AST as your code structure changes
- Hover over type annotations to see detailed property information
- Hover over node keys to see corresponding Luau code
- Perfect for experimentation and learning AST structure
- Input two code snippets in separate editors
- Click "Analyze Transformation" to see differences
- Visual diff highlighting shows exactly what changed
- Type tooltips and code tooltips work in diff mode for enhanced analysis
- Before/after type annotations show how types transform
- Understand code transformations for refactoring and codemod work
# Clone the repository
git clone https://github.com/wmccrthy/LuauASTExplorer.git
cd LuauASTExplorer
# Install dependencies
npm install
cd frontend && npm install && cd ..
# Install Lute with foreman...
foreman install
# or with rokit...
rokit install# Development build with watch mode
npm run watch
# Production build
npm run compile
# Package extension
vsce package# Run frontend tests
npm test
# Run Lua tests
lute run lua_tests/runner.luauโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ VSCode Extension โ
โโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ Backend โ Frontend โ External Tools โ
โ (Node + Luau) โ (React) โ โ
โ โ โ โ
โ โข extension.ts โ โข App.tsx โ โข Lute (Luau parser) โ
โ โข astParser.ts โ โข TreeNode.tsx โ โข json-diff-ts โ
โ โข Luau helpers โ โข TypeTooltip โ โข highlight.js โ
โ โข Type system โ โข diffUtils.ts โ โข Foreman (tool mgmt) โ
โโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโ
Data Flow:
(initial code-> AST translation) Luau Code โ Lute Parser โ typeAnnotations.lua (adds _astType) โ JSON โ React UI
(node hover AST -> code translation) React UI Node โ astJsonToCode.luau โ lutePrinter.luau โ Generated Src Code โ Tooltips in React UI
LuauASTExplorer/
โโโ src/ # VSCode extension backend
โ โโโ extension.ts # Main entry point
โ โโโ astParser.ts # Lute integration & communication
โโโ frontend/ # React frontend
โ โโโ src/
โ โ โโโ App.tsx # Main React component
โ โ โโโ components/ # UI components
โ โ โ โโโ TreeNode.tsx # AST tree rendering
โ โ โ โโโ TypeTooltip.tsx # Interactive type tooltips
โ โ โ โโโ CodeTooltip.tsx # Code translation tooltips
โ โ โ โโโ LiveEditor.tsx # Live editing mode
โ โ โ โโโ DiffAnalyzer.tsx # Diff analysis mode
โ โ โ โโโ CodeEditor.tsx # Code input component
โ โ โโโ utils/ # Core utilities
โ โ โ โโโ astTypeDefinitions.ts # Complete Luau AST type definitions
โ โ โ โโโ astTypeHelpers.ts # Type inference & manipulation
โ โ โ โโโ diffUtils.ts # Diff annotation
โ โ โ โโโ syntaxHighlighting.ts # Code highlighting & theme detection
โ โ โ โโโ nodeEmphasisHelpers.ts # Auto-collapse logic
โ โ โ โโโ parsingMessageHandlers.ts # VSCode communication
โ โ โโโ context/ # React context
โ โ โ โโโ codeTranslationContext.ts # Code tooltip state management
โ โ โโโ hooks/ # Custom React hooks
โ โ โ โโโ useCodeTranslation.ts # Code translation logic
โ โ โโโ types/ # TypeScript definitions
โ โ โ โโโ typesAndInterfaces.ts # Shared type definitions
โ โ โโโ tests/ # Frontend test suites
โ โ โโโ TreeNode.test.tsx # Comprehensive component tests
โ โ โโโ astTypeHelpers.test.ts # Type system tests
โ โ โโโ diffUtils.test.ts # Diff algorithm tests
โ โ โโโ nodeEmphasisHelpers.test.ts # Auto-collapse tests
โ โ โโโ syntaxHighlighting.test.ts # Syntax highlighting tests
โ โโโ build/ # Built React app
โโโ lua_helpers/ # Luau scripts for parsing
โ โโโ astToJson.luau # Main AST serialization script
โ โโโ astJsonToCode.luau # AST to code conversion
โ โโโ typeAnnotations.lua # Enhanced type annotation system
โ โโโ sortByPositionTable.lua # AST position sorting utilities
โ โโโ temp_vendor/
โ โโโ lutePrinter.luau # Luau code generation engine
โโโ lua_tests/ # Lua test suites
โ โโโ runner.luau # Test runner
โ โโโ typeAnnotations.spec.lua # Type annotation tests
โ โโโ printASTNode.spec.lua # Code generation tests
โ โโโ astJsonToCode.spec.lua # AST conversion tests
โ โโโ helpers/ # Test utilities
โ โโโ astJsonToCodeHelpers.lua # Test case definitions
โ โโโ typeAnnotationTestHelpers.lua # Type testing utilities
โโโ ci_scripts/ # Build automation
โ โโโ readChangelog.ts # Changelog processing
โโโ docs/ # Documentation assets
โ โโโ ASTExplorerDiffGIF.gif
โ โโโ ASTExplorerLiveEditorGIF.gif
โโโ .github/workflows/ # GitHub Actions
โ โโโ release.yml # Automated VSIX packaging
โ โโโ ci.yml # Continuous integration
โโโ package.json # Extension manifest
โโโ README.md # This file
We welcome contributions! Here's how to get started:
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Make your changes and test thoroughly
- Commit your changes:
git commit -m 'Add amazing feature' - Push to the branch:
git push origin feature/amazing-feature - Open a Pull Request
- Follow TypeScript best practices
- Add tests for new functionality (both frontend and Lua)
- Update documentation as needed
- Test with various Luau code samples
- Use conventional commit messages for changelog automation
Use these formats for automatic changelog creation:
#feat Add new feature descriptionโ Creates feature changelog entry#bug Fix issue descriptionโ Creates bug fix changelog entry#chore Update documentationโ No changelog entry (maintenance)
- VSCode 1.74.0 or higher
- Lute (>= 0.1.0-nightly.20260312)
- Foreman or Rokit (See installation instructions linked above)
- Node.js 16+ (for development)
- Large AST trees (1000+ nodes) may have performance impact
- Some complex and niche types may not display perfectly in tooltips
- Code translation works for most AST nodes but may fall back to path display for edge cases (eg, Trivia, Position, Location)
This project is licensed under the MIT License - see the LICENSE file for details.
- luau-lang for all the luau tooling
- rxi for a lua json library
- json-diff-ts for robust JSON diffing capabilities
- highlight.js for syntax highlighting
- GitHub Issues: Report bugs or request features
- Discussions: Ask questions or share ideas
Made with โค๏ธ for the Luau/Roblox development community

