JSON to Rust Converter

Generate Rust structs from JSON. Paste your JSON:

Loading...
Loading...

Generate Rust Structs from JSON

This tool converts JSON to Rust structs with Serde derive macros for serialization and deserialization.

Example Output

use serde::{Deserialize, Serialize};

#[derive(Serialize, Deserialize, Debug, Clone)]
#[serde(rename_all = "camelCase")]
pub struct User {
    pub id: i32,
    pub user_name: String,
    pub is_active: bool,
}

Type Mapping

JSONRust
stringString
integeri32 / i64
decimalf64
booleanbool
nullOption<String>
arrayVec<T>
objectNested struct

Using Generated Code

// Add to Cargo.toml:
// serde = { version = "1.0", features = ["derive"] }
// serde_json = "1.0"

let json = r#"{"id": 1, "userName": "john"}"#;
let user: User = serde_json::from_str(json)?;
println!("{:?}", user);

Related Tools