9 unstable releases (3 breaking)

Uses new Rust 2024

0.3.2 Dec 27, 2025
0.3.1 Dec 9, 2025
0.2.0 Jul 28, 2025
0.1.2 Mar 16, 2025
0.0.2 Aug 29, 2024

#200 in Data formats

Download history 1702/week @ 2025-11-09 1464/week @ 2025-11-16 1885/week @ 2025-11-23 2601/week @ 2025-11-30 3124/week @ 2025-12-07 3520/week @ 2025-12-14 1115/week @ 2025-12-21 3256/week @ 2025-12-28 3285/week @ 2026-01-04 3821/week @ 2026-01-11 3902/week @ 2026-01-18 2885/week @ 2026-01-25 3301/week @ 2026-02-01 2932/week @ 2026-02-08 5448/week @ 2026-02-15 3334/week @ 2026-02-22

15,363 downloads per month
Used in 14 crates (3 directly)

MIT/Apache

570KB
13K SLoC

Rust 12K SLoC // 0.0% comments LALRPOP 1.5K SLoC // 0.1% comments

wgsl-parse

A parser and syntax tree for WGSL files, written directly from the specification with lalrpop.

It supports WESL language extensions guarded by feature flags.

WESL Features

name description WESL Specification
wesl enable all WESL extensions below
imports import statements and inline qualified paths complete
attributes extra attributes locations on statements complete
condcomp @if attributes complete
generics @type attributes experimental

Other Features

name description
naga-ext enable all Naga/WGPU extensions (experimental)
serde derive Serialize and Deserialize for syntax tree nodes
tokrepr derive TokRepr for syntax tree nodes

Parsing and Stringification

TranslationUnit implements FromStr. Other syntax nodes also implement FromStr: GlobalDirective, GlobalDeclaration, Statement, Expression and ImportStatement.

The syntax tree elements implement Display. The display is always pretty-printed.

# use wgsl_parse::syntax::TranslationUnit;
# use std::str::FromStr;
let source = "@fragment fn frag_main() -> @location(0) vec4f { return vec4(1); }";
let mut module = TranslationUnit::from_str(source).unwrap();
// modify the module as needed...
println!("{module}");

Dependencies

~6–8.5MB
~136K SLoC