About this tool
The JSON to Rust Serde Structs tool converts a pasted JSON sample into Rust structs annotated for serde, so you can deserialize the same payload without hand-writing every field. It parses the JSON, infers Rust types recursively, and emits a #[derive(Serialize, Deserialize, ...)] struct per object: strings become String, integers i64 (or u64 when all samples are non-negative), other numbers f64, booleans bool, arrays Vec<T>, and nested objects their own PascalCase structs defined before their parents.
All work happens locally in your browser with JSON.parse and plain JavaScript — nothing is uploaded. Struct fields are converted to snake_case, and whenever a JSON key differs from the snake_case field the tool adds #[serde(rename = "originalKey")] so the struct still maps to the wire format. Keys that are absent in some sibling samples, or seen as null, become Option<T> with #[serde(default)] so deserialization tolerates their absence. Empty arrays fall back to Vec<serde_json::Value>.
The integer-width toggle switches between 64-bit (i64/u64, default) and 32-bit (i32/u32) integers, promoting to 64-bit automatically when a sampled value exceeds the 32-bit range. The derive toggle chooses between the full set (Serialize, Deserialize, Debug, Clone) and a minimal Serialize, Deserialize. The file starts with use serde::{Serialize, Deserialize};. Copy it or download a .rs file.