JSON to Rust Struct

Generate Rust structs with Serde derive macros from JSON data. Produces idiomatic snake_case fields with proper type mapping and serde rename attributes.

Input JSON
Rust Struct Output

Features

🦀 Idiomatic Rust

  • snake_case field names
  • Serde derive macros
  • pub struct and pub fields
  • Nested struct generation

📦 Serde Integration

  • #[derive(Serialize, Deserialize)]
  • #[serde(rename)] for camelCase keys
  • Option<T> for nullable fields
  • Vec<T> for arrays

⚙️ Configurable Output

  • Selectable integer types
  • Optional Clone derive
  • Configurable pub visibility
  • All-nullable option

Rust Serde Guide

Serde Derive Macros

Serde is Rust's serialization framework. Add it to your Cargo.toml and use derive macros for zero-cost JSON serialization.

# Cargo.toml
[dependencies]
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
use serde::{Deserialize, Serialize};

#[derive(Debug, Serialize, Deserialize)]
pub struct User {
    pub id: i64,
    pub name: String,
    #[serde(rename = "isActive")]
    pub is_active: bool,
}