JSON to Rust Struct Converter (serde)
Paste any JSON object or array and get ready-to-use Rust `struct` definitions deriving `Serialize, Deserialize` from serde, with fields mapped to Rust types (String, i64, f64, bool, Vec<...>) and separate structs for nested objects. Keys that aren't snake_case get a `#[serde(rename = "...")]` attribute. Everything runs locally in your browser — your JSON is never uploaded.
How to use
- Paste or type your JSON into the input box.
- Optionally rename the root struct (defaults to AutoGenerated).
- Copy the generated structs from the output box and add serde to your Cargo.toml.
Frequently asked questions
- How are numbers typed?
- Whole numbers become i64 and numbers with a decimal point become f64. Adjust manually if you need u32, i32 or another width.
- What happens with null or empty arrays?
- null values map to Option<serde_json::Value> and empty arrays to Vec<serde_json::Value>, since their type can't be inferred from the sample.
- Why do some fields have a serde rename?
- Rust fields use snake_case. When a JSON key differs (for example camelCase), a #[serde(rename = "...")] attribute is added so serialization still matches the original key.
- Is my JSON sent anywhere?
- No. Conversion happens entirely in your browser; nothing is uploaded.
Related tools
JSON to Go Struct Converter
Turn a JSON object into a typed Go struct with json tags, instantly in your browser.
JSON to Python Dataclass Converter
Turn a JSON object into Python @dataclass definitions with type hints, in your browser.
JSON to Kotlin Data Class Converter
Turn a JSON object into Kotlin data classes with typed properties, in your browser.
JSON to C# Class Converter
Turn a JSON object into C# classes with auto-property type mapping, in your browser.
JSON to Java Class (POJO) Converter
Turn a JSON object into Java POJO classes with type-mapped fields, in your browser.
JSON to GraphQL Schema (SDL) Converter
Turn a JSON object into GraphQL type definitions (SDL) with scalar mapping, in your browser.