Output will appear here
Output will appear here
Generate Rust structs from JSON with serde Serialize and Deserialize derives using this free online converter. The tool produces idiomatic Rust types with Option<T> for nullable fields, Vec<T> for arrays, and #[serde(rename)] attributes for key mapping.
Try Convert All - paste JSON once, see TypeScript, Go, YAML, and 15 more formats instantly.
Paste a JSON object or array into the input panel. The converter supports nested structures, mixed-type arrays, and optional fields with null values.
The output shows Rust structs annotated with #[derive(Serialize, Deserialize, Debug)] from the serde crate. Fields use idiomatic snake_case names with #[serde(rename = "...")] where the JSON key differs.
Copy the output into your src/ directory. Add serde, serde_json, and serde_derive to your Cargo.toml dependencies, then call serde_json::from_str to parse JSON into your new structs.
Paste your JSON here to generate structs with #[derive(Deserialize)] already applied. In your Rust code, call serde_json::from_str::<Root>(&json_string) to parse the JSON into the generated Root struct. All nested types are included so deserialization works recursively.
Yes. Any field whose value is null in the sample JSON is typed as Option<T>. During deserialization, serde treats missing keys and null values as None, which is idiomatic Rust for representing absent data.
Each struct derives Serialize, Deserialize, and Debug. Fields whose JSON keys use camelCase or contain special characters get a #[serde(rename = "originalKey")] attribute so the Rust field name stays in snake_case.
Whole numbers map to i64 and decimal numbers to f64. If an array mixes integers and floats, the element type is promoted to f64. Extremely large numbers that exceed i64 range are also mapped to f64.
Absolutely. Since the structs implement serde Deserialize, you can pass them as the generic type in reqwest's .json::<Root>() method or as actix-web extractor types like web::Json<Root> for request body parsing.