Skip to content
Course outline

Gherkin checker and formatter

Paste a feature file; it finds the syntax errors, gives style hints for clear scenarios, and formats the file.

  • Free, no sign-up
  • Runs in your browser
  • Nothing you type is sent anywhere

Gherkin is the plain-language format of behaviour-driven development (BDD): Given a situation, When someone acts, Then something can be observed. Product owners can read it, and tools like Cucumber and SpecFlow run it as tests. A small slip (a missing keyword, an Examples table with a column too few) stops the whole file from running.

Paste a feature file. The checker lists its syntax errors by line, gives style hints that make scenarios clearer, and writes the file back neatly formatted, with the table columns lined up. It reads English keywords, and nothing you paste leaves this page.

Use the tool

No errors. 2 style hints:

  • Line 4 Use one When per scenario: this one has 2. Split it, so each scenario checks one action.
  • Line 13 A Then checks what someone can observe; "click" is an action, so it belongs in a When.

Formatted:

Feature: Coupons at checkout
  A shopper takes money off with one coupon code.

  Scenario: A valid code lowers the total once
    Given a basket with The Cedar Tree at 19.00
    When I type CEDAR10
    And I click Apply
    Then the total is 17.10

  Scenario Outline: A refused code says why
    Given a basket with The Cedar Tree at 19.00
    When I apply the code <code>
    Then I click the message "<message>"

    Examples:
      | code      | message                          |
      | EXPIRED24 | This code expired on 31 Dec 2024 |
      | SPRING25  | This code has been used up       |

How the method works

A feature file starts with "Feature:" and holds scenarios. Each scenario has steps: Given (the starting situation), When (the action), Then (the outcome), with And and But continuing the step before. A Scenario Outline runs once for each row of its Examples table, putting each column's value in place of its <name>.

The style hints follow the habits of good BDD: one When per scenario, so each scenario checks one behaviour; a Then that states what someone can observe, not another click; Given, When and Then in that order; and Examples whose columns all appear in the steps. A file can run with hints; it cannot run with errors.

  1. Paste the feature file, or write one here.
  2. Fix the errors first: each names its line.
  3. Read the hints, change what makes the scenarios clearer, then copy the formatted file.

A worked example on Cedar Books

Two scenarios for coupons at Cedar Books (REQ-03 and REQ-06), written in a hurry: keywords in lower case, a When in two steps, a Then that clicks. The checker finds no errors but gives two hints, and formats the file:

  • Line 4 Use one When per scenario: this one has 2. Split it, so each scenario checks one action.
  • Line 13 A Then checks what someone can observe; "click" is an action, so it belongs in a When.
Feature: Coupons at checkout
  A shopper takes money off with one coupon code.

  Scenario: A valid code lowers the total once
    Given a basket with The Cedar Tree at 19.00
    When I type CEDAR10
    And I click Apply
    Then the total is 17.10

  Scenario Outline: A refused code says why
    Given a basket with The Cedar Tree at 19.00
    When I apply the code <code>
    Then I click the message "<message>"

    Examples:
      | code      | message                          |
      | EXPIRED24 | This code expired on 31 Dec 2024 |
      | SPRING25  | This code has been used up       |

The hints say to keep one When per scenario (type the code and apply it in one step), and to make the second Then an observation: "Then the message says ..." instead of a click.

Learn more

Put the lessons to work on a real site

Describe a user journey in plain English. QAIA walks it in a real browser and hands back the test cases, the automation code and the evidence of every step.