A TypeScript library for formatting Gherkin AST models back into Gherkin feature file strings. Current stable version is 1.2.2, released under the Gherking organization. It provides a format() function that takes a Document AST node (from gherkin-ast) and optional FormatConfig options to control tag layout, line breaks, indentation, and compact output. Key differentiator: it is part of the gherking ecosystem, designed to work with gherkin-ast and gherkin-io for parsing, manipulating, and writing Gherkin documents programmatically.
npm install gherkin-formatterNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Read a Gherkin file, parse to AST, format with custom options, and output the formatted Gherkin string.
Use FormatConfig instead of FormatOptions in type annotations.
Access the first element of the array returned by read(): format(docs[0], options).
Set indentation explicitly in options or update tests that rely on the old default.
Upgrade Node to 12 or later.
npm install gherkin-ast
Use `import { format } from 'gherkin-formatter'` instead of `import gherkinFormatter from 'gherkin-formatter'`Call format on individual document: format(docs[0], options)