Code Generators · Runs in your browser
JSON to Rust Struct Generator (Serde)
Paste a JSON sample and get ready-to-use Rust structs, with nested types, arrays and optional fields worked out for you. Ideal for deserializing with serde and serde_json.
JSON
Drop a file to load it
Rust
How to use it
- Paste a representative JSON sample, such as an API response.
- Set the root type name and pick a style: serde structs.
- Copy the Rust code or download it as a file.
Serde attributes
Structs derive Serialize and Deserialize, and #[serde(rename = "…")] keeps the original key names.
Option
Fields that may be missing or null become Option<T> with #[serde(default)].
Integers vs. decimals
Number types come from how the number is written in your sample: 3 is an integer, 3.0 and 3.5 are decimals, and long IDs use a 64-bit type.
More code generators tools
All free, all private, all running locally in your browser.