Solutions in this repo
May 12, 2026 ยท View on GitHub
grammars/dart.json
The primary TextMate language grammar for Dart. This grammar is used by most editors and websites to provide syntax highlighting for Dart code.
It includes support for modern Dart features, including:
- Dart 3.x: Patterns (
switchexpressions,if-case), Records, Class Modifiers (sealed,base,interface,final), and Extension Types. - Macros & Augmentations: Support for
macro,augment, andaugmented.
Used by:
- Editors:
- Dart-Code extension for VS Code.
- VS Code's built-in Dart basic language support.
- Websites & Documentation:
- GitHub via Linguist.
- dart.dev and docs.flutter.dev via Shiki.
- Dart & Flutter DevTools.
- Packages:
package:syntax_highlight- A Flutter package for syntax highlighting using this grammar.
Updating the Grammar
When updating the grammar, consider raising issues (or PRs) to update the following files which may not have automated updates from this repository:
- Dart-Code/Dart-Code/syntaxes/dart.json
- flutter/devtools/packages/devtools_app/assets/dart_syntax.json
Other solutions
These projects use different highlighting engines and maintain their own Dart grammars.
Tree-sitter
Tree-sitter is an incremental parsing system. There is no official tree-sitter grammar for Dart, but there are active community implementations:
highlight.js
highlight.js is a JavaScript-based syntax highlighter.
- Dart-specific implementation
- Used by:
CodeMirror
CodeMirror is a web-based code editor.
- CodeMirror 5 Dart mode (Used by DartPad).
- CodeMirror 6 supports Dart via
@codemirror/legacy-modes.
PrismJS
Prism is a lightweight, extensible syntax highlighter.