How to use
- Paste a JSON sample, or click Load sample.
- Set the name of the root struct.
- Copy or download the code. Add serde with the derive feature and serde_json to Cargo.toml.
Options explained
- Root type name
- Name of the top-level struct. Nested structs are named after their keys.
Examples
{"userName": "ada", "type": "admin"} becomes:
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Root {
#[serde(rename = "userName")]
pub user_name: String,
pub r#type: String,
}
Frequently asked questions
Which crates do I need?
serde with the derive feature, and serde_json to parse. serde_json::Value is used for values whose type cannot be inferred.
How are Rust keywords handled?
Keys such as type become raw identifiers (r#type). serde removes the r# prefix, so no rename is needed.
What number types are used?
i64 for whole numbers and f64 for numbers with decimals.
Is my JSON uploaded?
No. The types are generated in your browser, so API responses with real data stay on your device.
Privacy
This tool runs entirely in your browser. Your files and text are processed on your device and are never uploaded to our servers.