JSON to Rust Serde Struct
Rust / Serde
Generate idiomatic Rust structs with #[derive(Serialize, Deserialize)], automatic #[serde(rename)] attributes, and nested struct inference.
About This Tool
Working with JSON APIs in Rust via serde and serde_json requires explicit struct definitions for every nested object level. Hand-writing #[serde(rename = "...")] attributes for camelCase fields and escaping Rust keywords like type or match is repetitive boilerplate.
This generator parses any JSON object or array in your browser and produces ready-to-compile Rust structs with Debug, Clone, PartialEq, Serialize, and Deserialize derives.
Key Features
- Raw Identifier Escaping: Automatically prefixes Rust keywords (type, match, mod, fn, ref) with r# so generated code compiles without warnings.
- Serde Rename Annotations: Translates camelCase and kebab-case keys to idiomatic snake_case fields while preserving wire compatibility via #[serde(rename)].
- Nested Struct Extraction: Recursively extracts nested objects and object arrays into strongly typed child structs.