
nom
A Rust library for building fast, safe parsers by combining small parsing functions.
- Stars
- 10.5k
- Forks
- 848
- Licence
- MIT
- Language
- Rust
- Last update
- 1.2 years ago
- Type
- Library
No commits in over a year — check for forks or alternatives before adopting.
What it is
nom is a parser combinators library written in Rust. You build parsers by assembling small functions, such as 'take 5 bytes' or 'recognize the word HTTP', into larger patterns that look like the grammar they describe. It is designed for reading binary formats, text formats, and streaming data without copying input unnecessarily.
- Parse a hexadecimal color such as #2F14DF into its red, green, and blue values, as shown in the README example
- Write parsers for binary formats like TLV structures or bit-level data
- Parse text formats such as CSV, JSON, or TOML
- Build streaming parsers that report when they need more data before producing a result
Great for
- Rust developers writing parsers for binary or text file formats
- Developers parsing network protocols or data that arrives in chunks
- Engineers prototyping a parser for a programming language or data format
- Developers who want parsers that are small, testable, and reusable
Not ideal for
- People who are not writing Rust code, since this is a Rust-only library
- Projects needing a ready-made tool that reads a grammar file and generates a parser, since nom is code you write by hand with combinators
- Beginners new to Rust, because the README's examples rely on Rust's type system and error handling
How to get it
- 1
Install with a package manager
You'll need: Rust toolchain (rustc 1.65.0 or newer, per the README badge and MSRV section)
Add nom to a Rust project
cargo add nom - 2
Run it
- Add nom to your Cargo project with cargo add nom
- Copy the hexadecimal color example from the README into src/main.rs
- Run it with cargo run to see the parsed color printed
- Run cargo test to check the included parse_color test
- 3
Get the most out of it
- Read the Nominomicon guide linked in the README for a structured introduction
- Use the combinator list in doc/choosing_a_combinator.md to pick the right building blocks
- Add nom_locate, which the README mentions, to report exact line and column positions in errors
- Use the streaming mode when your input arrives in chunks or comes from a network connection
Downloads
Strengths
- The README says it is designed to be fast and memory-safe, with benchmarks it reports as competitive with several other parser libraries and handwritten C parsers
- Parsers are assembled from small reusable pieces that are easy to test separately
- Error reporting can aggregate error codes and custom error types
Trade-offs
- You write parsers in Rust code with combinator functions, which takes learning before it feels natural
- The README's documentation links point to external resources such as a guide and reference docs, so getting started depends on them
- The README notes a minimum Rust version of 1.65 and the latest series is referred to as 8.0, so check compatibility with your toolchain
How it compares
| Project | Stars | Type | Level | Updated | Best for |
|---|---|---|---|---|---|
| nom (this) | 10.5k | Library | intermediate | 1.2 years ago | Rust developers writing parsers for binary or text file formats |
| pest | 11.8k | Library | intermediate | 5 days ago | PHP developers who want to add automated tests to a project |
| cheerio | 30.5k | Library | beginner | 4 days ago | JavaScript developers who already know jQuery-style selectors |
| tree-sitter | 27.4k | Library | advanced | 4 days ago | Developers building code editors or IDE features that need to understand source code as it changes |
| parsedown | 15k | Library | beginner | 9 months ago | PHP developers who need to render Markdown inside a PHP web application |
| go | 13.9k | Library | beginner | 2.4 years ago | Go developers who parse or produce large amounts of JSON and want to test a faster option |
Stats synced from GitHub. The assessment above was drafted with AI from the project's README on 2026-10-29 and may miss recent changes — check the README before relying on a command. MIT licence: free to use, modify and distribute, including commercially, as long as you keep the copyright notice.