explaingit

zesterer/chumsky

4,540RustAudience · developerComplexity · 3/5Setup · moderate

TLDR

A Rust library for building parsers by snapping together small reusable pieces, with built-in error recovery that produces clear messages when parsing fails, ideal for programming languages, config formats, and binary protocols.

Mindmap

mindmap
  root((repo))
    What it does
      Parser combinator library
      Error recovery
      Zero-copy output
    Key Features
      Composable pieces
      Type-safe building
      Recursive grammars
      Memoization mode
    Use Cases
      Programming languages
      Config file parsers
      Binary protocols
      Interpreters
    Learning Resources
      JSON example
      Brainfuck example
      Tutorial walkthrough
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Build a parser for a custom programming language or configuration format using composable Rust building blocks

USE CASE 2

Write a parser with good error recovery so users see helpful messages instead of a single cryptic failure line

USE CASE 3

Parse recursive or nested structures like function calls and arithmetic expressions with type-safe grammar rules

USE CASE 4

Follow the included tutorial to build a small working interpreter from scratch using real examples

Tech stack

Rustcrates.io

Getting it running

Difficulty · moderate Time to first run · 30min

Requires familiarity with Rust's type system, the combinator pattern has a learning curve for developers new to Rust.

The license is described as open-source but the specific terms are not named in the explanation.

In plain English

Chumsky is a library for the Rust programming language that helps developers write parsers. A parser is a piece of software that reads structured text or data and turns it into something a program can work with. For example, a parser might read a line of code and figure out what operation it describes, or it might read a configuration file and extract settings from it. Chumsky is aimed at developers who need to build this kind of text processing for things like programming languages, config formats, binary protocols, or any other structured input. The library uses a style called parser combinators, which means you build complex parsing logic by combining smaller, simpler pieces. Think of it like Lego blocks: each block does one small job (match a digit, match a keyword, match something in brackets), and you snap them together to describe bigger structures. Rust's type system checks that these pieces fit together correctly as you write the code, catching many mistakes before the program ever runs. Chumsky emphasizes good error messages. When parsing fails, the library includes built-in strategies to recover from errors and continue, rather than stopping at the first problem. This is particularly valuable when building tools for other developers, where a cryptic single-line error message is frustrating but a clear explanation of what went wrong is genuinely helpful. Other features include support for grammars where rules refer back to themselves (recursive structures), an optional memoization mode for performance on certain input types, zero-copy output so the library avoids unnecessary memory allocation, and a compatibility mode for environments without the standard library, such as embedded hardware. The project has moved its primary home to Codeberg, though this GitHub repository remains. Documentation includes a detailed guide, examples for parsing JSON and Brainfuck, and a tutorial that walks through building a small interpreter from scratch. It is available as a published crate on crates.io under an open-source license.

Copy-paste prompts

Prompt 1
Using chumsky, write a Rust parser that reads arithmetic expressions like '3 + 4 * 2' and evaluates them with correct operator precedence. Show the full working code.
Prompt 2
With chumsky, help me parse a config file where each line is 'key = value' with optional '#' comments, and include error recovery so one bad line does not stop the rest from parsing.
Prompt 3
I'm building a programming language in Rust. Show me how to use chumsky to define recursive grammar rules for parsing nested function calls like 'foo(bar(1, 2), 3)'.
Prompt 4
Using chumsky's zero-copy mode, write a parser for a CSV-like format that avoids allocating strings for each field and returns slices of the original input instead.
Prompt 5
How do I add a custom error type to a chumsky parser so that parse failures include domain-specific context rather than generic 'expected X found Y' messages?
Open on GitHub → Explain another repo

← zesterer on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.