JSON to Rust struct generator
Convert any JSON sample to a Rust struct with `#[derive(Serialize, Deserialize)]`. Output drops into a serde-based project without edits.
# context
Rust's serde ecosystem is the standard for JSON. Each struct needs explicit derives and field types; getting them right by hand on a deeply nested response is error-prone. This tool emits the struct plus `use serde::{Deserialize, Serialize};` so it compiles immediately.
JSON input
{
"id": 1,
"name": "Ada Lovelace",
"email": "[email protected]",
"active": true,
"roles": ["admin", "engineer"],
"createdAt": "2026-05-14T00:00:00Z"
} Output preview
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize)]
pub struct User {
pub id: i64,
pub name: String,
pub email: String,
pub active: bool,
pub roles: Vec<String>,
#[serde(rename = "createdAt")]
pub created_at: String,
} → Open in JSON to Types generator (pre-filled)
# notes
- snake_case field names are emitted with `#[serde(rename = "camelCaseKey")]` to round-trip JSON correctly.
- For nullable values, the field becomes `Option<T>` — quicktype detects this when your sample has the field absent or set to `null`.
- Add `chrono::DateTime` for proper date parsing after generation; the default keeps dates as `String` to avoid forcing a chrono dependency.