Loading...
0%

Theory of Automata & Formal Languages

Context-Free Grammar Normal Form Converter

Convert any CFG to Chomsky Normal Form or Greibach Normal Form with step-by-step transformations, CYK parsing, FIRST/FOLLOW sets, and parse tree visualization.

0 CNF Steps
0 GNF Steps
0 Analysis Tools
Chomsky· Greibach· CYK Algorithm· Parse Trees· FIRST/FOLLOW· ε-Elimination· Unit Removal· Left Recursion· Chomsky· Greibach· CYK Algorithm· Parse Trees· FIRST/FOLLOW· ε-Elimination· Unit Removal· Left Recursion·
Scroll

Everything you need for CFG analysis

A comprehensive toolkit for grammar transformations, parsing, and visualization

CNF Conversion

ε-elimination, unit removal, and binarization in 6 detailed steps

Core

GNF Conversion

Left-recursion elimination and terminal substitution in 9 steps

Core

CYK Algorithm

String membership testing with visual triangular parsing table

Parsing

FIRST & FOLLOW Sets

Tabular computation of FIRST and FOLLOW for every variable

Analysis

Parse Trees

Canvas-rendered trees with leftmost derivation tracing

Visual

Diff & Export

Before/after comparison, clipboard copy, and .txt export

Utility

Three simple steps

From grammar input to fully converted normal form

1

Enter Your Grammar

Type productions directly or use the structured form. Load built-in examples to get started quickly.

2

Choose Conversion

Select CNF, GNF, or both. The converter applies each transformation step-by-step with full explanations.

3

Analyze & Test

Test strings with CYK parsing, view FIRST/FOLLOW sets, explore parse trees, and export your results.

Grammar Normal Forms Explained

Understanding Context-Free Grammars and their standard transformations

CFG

Context-Free Grammar

A Context-Free Grammar consists of rules where a single non-terminal variable expands into any sequence of variables and terminals. It is heavily used in compiler design, string parsing, and defining programming language syntax.

A → α
CNF

Chomsky Normal Form

In CNF, every production rule expands a variable into exactly two variables, or into a single terminal. This strictly binary structure enables efficient algorithms like CYK to parse a string of length n in O(n³) time.

A → BC or A → a
GNF

Greibach Normal Form

In GNF, every production rule starts with exactly one terminal symbol, followed by zero or more variables. This form guarantees that each step consumes one input character, which is ideal for top-down parsers and Pushdown Automata.

A → aα

Input Grammar

Syntax reference
  • A-Z non-terminals (variables)
  • a-z 0-9 terminals
  • or -> production arrow
  • | alternatives
  • ε or eps empty string
  • First LHS = start symbol
123
Examples:
Ctrl+Enter convert · navigate steps · Space auto-play