JSON to Rust Struct
Convert JSON into Rust structs that derive serde Serialize and Deserialize, with snake_case fields, rename attributes, Option and Vec types. Free and private.
Runs in your browser. Nothing is uploaded.
About JSON to Rust Struct
JSON to Rust generates structs ready for serde_json: each derives Debug, Clone, Serialize and Deserialize, fields use snake_case with #[serde(rename)] where the JSON key differs, numbers become i64 or f64, arrays become Vec<T> and missing or null values become Option<T>.
Add serde (with the derive feature) and serde_json to Cargo.toml and the output compiles as is.
How to use JSON to Rust Struct
- Type or paste your text into the input box. Press Sample to see an example.
- Adjust the options. The result updates as you type.
- Copy the result, or press Use as input to chain another transformation.
Frequently asked questions
Which crates do I need?
serde = { version = "1", features = ["derive"] } and serde_json = "1".
What about mixed-type values?
They become serde_json::Value, which can hold any JSON.
Is JSON to Rust Struct free and private?
Yes. JSON to Rust Struct is completely free with no sign-up. Everything runs in your browser, so whatever you type or paste never leaves your device.