Guide

THE TOOLBOX / RUST & CODEGEN

JSON to Rust Serde Generator —
Idiomatic Nested Rust Structs with #[serde(rename)] Locally.

Paste any API JSON payload to generate clean, idiomatic Rust structs with `serde::{Serialize, Deserialize}`, automatic `snake_case` field naming, reserved-keyword escaping, and `.rs` download.

Generated Rust Serde Structs
use serde::{Deserialize, Serialize};

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct RootPayload {
    #[serde(rename = "userId")]
    pub user_id: i64,
    pub username: String,
    #[serde(rename = "isVerified")]
    pub is_verified: bool,
    #[serde(rename = "balanceUsd")]
    pub balance_usd: f64,
    pub nickname: Option<serde_json::Value>,
    pub roles: Vec<String>,
    pub profile: Profile,
    pub orders: Vec<Order>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Order {
    #[serde(rename = "orderId")]
    pub order_id: String,
    pub total: f64,
    pub shipped: bool,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Profile {
    #[serde(rename = "displayName")]
    pub display_name: String,
    #[serde(rename = "joinedYear")]
    pub joined_year: i64,
}

RELATED CODEGEN TOOLS

Frequently Asked Questions

How does this JSON to Rust generator handle camelCase JSON keys?

It converts every Rust struct field to idiomatic `snake_case` (escaping Rust reserved keywords like `type` as `r#type`) and automatically attaches `#[serde(rename = "originalKey")]` so `serde_json` serializes and deserializes cleanly.

How are nested objects, arrays, and null values mapped to Rust types?

Nested JSON objects become separate PascalCase Rust structs, arrays become `Vec<T>`, integers map to `i64`, decimals map to `f64`, and `null` fields become `Option<serde_json::Value>`.

Does my JSON payload stay private in the browser?

Yes. All JSON parsing and Rust code generation happen 100% locally in your browser with zero API calls.