~/json-to-types

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

# other targets