# kach/nearley

📜🔜🌲 Simple, fast, powerful parser toolkit for JavaScript.

Repository: https://github.com/kach/nearley
Canonical: https://ross.abutalabs.com/products/nearley
Homepage: https://nearley.js.org
Language: JavaScript
License: MIT
License Family: permissive
Topics: parser, earley-algorithm, earley-parser, javascript, nodejs, nearley, node, parsing, parsing-library
Last push: 2024-11-14T02:34:00+00:00

## Health v2 (maintenance only)
Score: 23/100 (v2, computed 2026-09-03T02:39:23.370411+00:00)
- activity 0, release rhythm 8, longevity 100
- inputs: {"age_days": 4574, "days_push": 658, "days_rel": null, "gap_med": null, "n_releases_24m": 0}
- flags: none
- formula: round(0.45*activity + 0.35*rhythm + 0.20*longevity); archived -> min(score, 10)

## Adoption (not part of the score)
Stars 3742, forks 235 (observed 2026-08-28T04:08:15.993717+00:00)

## What it is
nearley is a JavaScript parser toolkit built on the Earley parsing algorithm, consisting of a BNF-based grammar DSL compiler and a lightweight streaming parser runtime. It handles any context-free grammar including left-recursive and ambiguous ones, works in Node.js and browsers, and ships with tooling for testing, unparser-based fuzzing, and railroad diagram generation.

## Use cases
- parse a custom DSL or configuration file format in JavaScript
- build a compiler frontend for a programming language
- parse file formats that PEG.js or Jison choke on, like left-recursive grammars
- handle ambiguous grammars and get all possible parse trees
- write a streaming parser for a REPL that consumes input incrementally
- generate railroad diagrams to document a grammar
- generate random valid strings from a grammar for fuzz testing
- teach or study parsing algorithms and computational linguistics

## When to choose
- you need to parse arbitrary or ambiguous context-free grammars, including left recursion
- you want a streaming parser with graceful error handling in Node or the browser
- you need all possible parsings for an ambiguous grammar
- you want tooling like fuzzers, railroad diagrams, and grammar tests out of the box
- you're building a DSL, markup language, or small language compiler in JavaScript

## When to avoid
- you need maximum parsing speed on simple LL(k) grammars where hand-written or PEG parsers are faster
- you want automatic AST generation with minimal boilerplate rather than writing postprocessors
- you're parsing a well-known format like JSON where a dedicated parser is simpler
- you need parser combinators or a runtime grammar-construction API instead of a compiled grammar file

## Facets
- artifact type: library
- maturity: stable
- function: parser, compiler, developer-tools
- domain: parsers, programming-languages, developer-tools
- platform: browser, cross-platform
- tags: earley-algorithm, parser-generator, grammar-dsl, streaming-parser, ambiguous-grammars, lexer-integration, railroad-diagrams, fuzzing, scannerless-parsing, natural-language-processing, nodejs, javascript

## Member repositories
- kach/nearley (main) score 23

## Provenance
- Observed fields: from GitHub, fetched 2026-08-28T04:08:15.993717+00:00.
- Health v2: computed from the inputs above; adoption is never an input.
- Inferred fields (summary, facets, guidance): AI-extracted, prompt v1, taxonomy v1, on 2026-08-29T18:29:05.807462+00:00, confidence not recorded.
  - readme: https://github.com/kach/nearley (fetched 2026-08-28T04:08:15.993717+00:00, sha a90accbfc661)
  - homepage: https://nearley.js.org (fetched 2026-08-29T09:23:53.511648+00:00, sha 6e3b2b7204ea)
  - site_page: https://nearley.js.org/docs/getting-started (fetched 2026-08-29T09:23:53.520874+00:00, sha d9ca49c3eccf)
  - site_page: https://nearley.js.org/docs/grammar (fetched 2026-08-29T09:23:53.522801+00:00, sha a25ee01b3fc3)
  - site_page: https://nearley.js.org/docs/parser (fetched 2026-08-29T09:23:53.525360+00:00, sha ee81b9a6c046)
  - site_page: https://nearley.js.org/docs/tokenizers (fetched 2026-08-29T09:23:53.527383+00:00, sha 51ef5cc85233)
  - site_page: https://nearley.js.org/docs/tooling (fetched 2026-08-29T09:23:53.529284+00:00, sha 7cba1da5ef37)
  - site_page: https://nearley.js.org/docs/how-to-grammar-good (fetched 2026-08-29T09:23:53.531620+00:00, sha 1f667060a658)
  - site_page: https://nearley.js.org/docs/using-in-frontend (fetched 2026-08-29T09:23:53.533974+00:00, sha 6af895a27794)
  - site_page: https://nearley.js.org/docs/glossary (fetched 2026-08-29T09:23:53.535912+00:00, sha 7bc89118cd69)
- Data as of 2026-08-30T08:39:29.467469+00:00.
