A library for formatting ANTLR4 grammar files, supporting a wide variety of formatting options. Current stable version is 2.1.5, released on a modest cadence with bug fixes and dependency updates. It is the only dedicated formatter for ANTLR4 grammars, offering fine-grained control over whitespace, alignment, and comment placement. The companion CLI package antlr-format-cli provides a command-line interface for batch processing.
npm install antlr-formatNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows how to import GrammarFormatter, instantiate with grammar string and options, then format and output.
Use import syntax or dynamic import().
Pass grammar content as string directly.
If tabs were desired, set useTab: true explicitly.
Upgrade to 2.1.1 or later.
Upgrade to 2.1.3 or later to exclude bundled dependencies.
Run `npm install antlr-format` and ensure import is correct: `import { GrammarFormatter } from 'antlr-format'`Use `import { GrammarFormatter } from 'antlr-format'`Switch to ESM import or use dynamic `import('antlr-format').then(...)`.