49 releases (12 stable)

2.1.1 Apr 15, 2019
2.1.0 Dec 21, 2018
2.0.2 Oct 21, 2018
1.0.6 Feb 21, 2018
0.3.2 Jun 28, 2016

#3 in Parser tooling

Download history 19265/week @ 2019-01-31 23775/week @ 2019-02-07 23227/week @ 2019-02-14 24222/week @ 2019-02-21 23124/week @ 2019-02-28 23554/week @ 2019-03-07 23398/week @ 2019-03-14 22594/week @ 2019-03-21 24387/week @ 2019-03-28 27692/week @ 2019-04-04 27459/week @ 2019-04-11 23262/week @ 2019-04-18 23374/week @ 2019-04-25 24638/week @ 2019-05-02 26608/week @ 2019-05-09

114,099 downloads per month
Used in 434 crates (111 directly)


11K SLoC



pest. The Elegant Parser

pest is a general purpose parser written in Rust with a focus on accessibility, correctness, and performance. It uses parsing expression grammars (or PEG) as input, which are similar in spirit to regular expressions, but which offer the enhanced expressivity needed to parse complex languages.

Getting started

The recommended way to start parsing with pest is to read the official book.

Other helpful resources:

  • API reference on docs.rs
  • play with grammars and share them on our fiddle
  • leave feedback, ask questions, or greet us on Gitter


The core of pest is the trait Parser, which provides an interface to the parsing functionality.

The accompanying crate pest_derive can automatically generate a Parser from a PEG grammar. Using pest_derive is highly encouraged, but it is also possible to implement Parser manually if required.

.pest files

Grammar definitions reside in custom .pest files located in the crate src directory. Parsers are automatically generated from these files using #[derive(Parser)] and a special #[grammar = "..."] attribute on a dummy struct.

#[grammar = "path/to/my_grammar.pest"] // relative to src
struct MyParser;

The syntax of .pest files is documented in the pest_derive crate.

Inline grammars

Grammars can also be inlined by using the #[grammar_inline = "..."] attribute.