What is JSON → Rust Struct?
Generate Rust structs from JSON data with serde Serialize and Deserialize derives.
Nested objects become their own structs with serde Serialize and Deserialize derives. Output updates as you type, and everything runs in your browser.
Features
- Generate Rust structs from JSON
- serde Serialize/Deserialize derives
- Option types for nullable fields
- Nested struct generation
- snake_case field naming
- Copy generated code to clipboard
How to use JSON → Rust Struct
- Paste your JSON. Enter a sample JSON object.
- Generate Rust code. Get Rust structs with serde derives.
- Copy and compile. Paste the generated structs into your Rust project.
Examples
Generating Rust structs
A small user record with a nested address, generated with the default settings. Comment header omitted.
Input
{
"id": 1,
"name": "Ada Lovelace",
"email": "ada@example.com",
"active": true,
"tags": ["admin", "dev"],
"address": { "city": "London", "zip": "EC1A" }
}Output
// }
use serde::{Serialize, Deserialize};
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Root {
pub id: i64,
pub name: String,
pub email: String,
pub active: bool,
pub tags: Vec<String>,
pub address: Address,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Address {
pub city: String,
pub zip: String,
}Frequently asked questions
Does it support serde?
Yes. Generated structs include #[derive(Serialize, Deserialize)] and #[serde(rename)] attributes.
Can I use this with Axum or Actix?
Yes. Works with any Rust web framework using serde for JSON serialization.
