# peggy

> Parser generator for JavaScript

Latest version **5.1.0** (published 2026-03-01) · MIT license · 0 weekly downloads

## Install

```sh
npm install peggy
pnpm add peggy
yarn add peggy
bun add peggy
```

Provides the command `peggy`.

## Health

**Score 55/100 (C)** — status: stable.

Positive: has types; no vulnerabilities; has provenance.

Warnings: low downloads; no esm support.

## Facts

| | |
|---|---|
| Version | 5.1.0 |
| Published | 2026-03-01 |
| First published | 2012-04-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=20 |
| Dependencies | 3 |
| Unpacked size | 578.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 1180 |
| Author | David Majda |
| Maintainers | clintjhill, hildjj, charlespick |
| Keywords | grammar, parser generator, PEG, PEG.js |

## Links

- npm: https://www.npmjs.com/package/peggy
- Repository: https://github.com/peggyjs/peggy
- Homepage: https://peggyjs.org/
- Issues: https://github.com/peggyjs/peggy/issues
- npm.io page: https://npm.io/package/peggy

## Dependencies (3)

- [commander](https://npm.io/package/commander.md) ^14.0.3
- [@peggyjs/from-mem](https://npm.io/package/@peggyjs/from-mem.md) 3.1.3
- [source-map-generator](https://npm.io/package/source-map-generator.md) 2.0.6

## Recent versions

- 5.1.0 (latest) — 2026-03-01
- 4.1.0-pre.2 (pre) — 2024-10-03
- 5.0.6 — 2025-08-05
- 5.0.5 — 2025-07-10
- 5.0.4 — 2025-06-20
- 5.0.3 — 2025-05-30
- 5.0.2 — 2025-05-07
- 5.0.1 — 2025-05-07
- 5.0.0 — 2025-05-03
- 4.2.0 — 2024-11-19
- 4.1.1 — 2024-10-03
- 4.1.0-pre.1 — 2024-10-03
- 4.1.0-pre.0 — 2024-10-03
- 4.0.3 — 2024-06-19
- 4.0.2 — 2024-02-26
- … 14 more at https://npm.io/package/peggy/versions

## README

[![Tests](https://github.com/peggyjs/peggy/actions/workflows/node.js.yml/badge.svg)](https://github.com/peggyjs/peggy/actions/workflows/node.js.yml)
[![npm version](https://img.shields.io/npm/v/peggy.svg)](https://www.npmjs.com/package/peggy)
[![codecov](https://codecov.io/gh/peggyjs/peggy/graph/badge.svg?token=9HBIZ9CRW8)](https://codecov.io/gh/peggyjs/peggy)
[![License](https://img.shields.io/badge/license-mit-blue.svg)](https://opensource.org/licenses/MIT)

# Peggy

Peggy is a simple parser generator for JavaScript that produces fast parsers
with excellent error reporting. You can use it to process complex data or
computer languages and build transformers, interpreters, compilers and other
tools easily.

Peggy is the successor of [PEG.js](https://github.com/pegjs/pegjs).

## Migrating from PEG.js

Peggy version 1.x.x is API compatible with the most recent PEG.js release.
Follow these steps to upgrade:

1. Uninstall `pegjs` (and `@types/pegjs` if you're using the DefinitelyTyped type definitions - we now include type definitions as part of peggy itself).
2. Replace all `require("pegjs")` or `import ... from "pegjs"` with `require("peggy")` or `import ... from "peggy"` as appropriate.
3. Any scripts that use the `pegjs` cli should now use `peggy` instead.
4. That's it!

## Features

- Simple and expressive grammar syntax
- Integrates both lexical and syntactical analysis
- Parsers have excellent error reporting out of the box
- Based on [parsing expression
  grammar](http://en.wikipedia.org/wiki/Parsing_expression_grammar) formalism
  — more powerful than traditional LL(_k_) and LR(_k_) parsers
- Usable [from your browser](https://peggyjs.org/online), from the command line,
  or via JavaScript API
- [Source map](https://developer.mozilla.org/en-US/docs/Tools/Debugger/How_to/Use_a_source_map) support

## Getting Started

[Online version](https://peggyjs.org/online) is the easiest way to generate a
parser. Just enter your grammar, try parsing few inputs, and download generated
parser code.

## Documentation

Full documentation is available at [peggyjs.org](https://peggyjs.org/documentation.html).

## Development

To get started, check out peggy, install the dependencies, and run build:

```bash
git clone https://github.com/peggyjs/peggy.git
cd peggy
npm install
(cd docs && npm install)
(cd web-test && npm install)
npm run build
npm run test:web
```

Please see the [Contribution Guidelines](CONTRIBUTING.md) for details on how
to contribute code.

## Links

- [Project website](https://peggyjs.org/)
- [Wiki](https://github.com/peggyjs/peggy/wiki)
- [Source code](https://github.com/peggyjs/peggy)
- [Issue tracker](https://github.com/peggyjs/peggy/issues)
- [Discussions](https://github.com/peggyjs/peggy/discussions)
- [Browser Benchmark Suite](https://peggyjs.org/development/benchmark.html)
- [Browser Test Suite](https://peggyjs.org/development/test.html)
- [Contribution Guidelines](CONTRIBUTING.md)
- [Discord Server](https://discord.gg/HU5tbEbwAB)

Peggy was originally developed by [David Majda](https://majda.cz/)
([@dmajda](http://twitter.com/dmajda)). It is currently maintained by
[Joe Hildebrand](https://github.com/hildjj) ([@hildjj](https://twitter.com/hildjj)).

You are welcome to contribute code. Unless your contribution is really trivial
you should [get in touch with us](https://discord.gg/HU5tbEbwAB)
first — this can prevent wasted effort on both sides.

---
_Source: https://npm.io/package/peggy · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
