100% Client-Side Engine • Zero Network Egress

JSON to Rust Serde Struct Converter

Instantly convert JSON objects and arrays into type-safe Rust structs with Serde derive macros. Supports reserved keyword safety, Option types, Chrono dates, and custom naming conventions.

Samples:
Derives:
JSON Input(440 bytes)
Rust Serde Output3 structs
// Generated by Nazamos (https://nazamos.com/json-to-rust)
// 100% Client-Side & Privacy-First Developer Suite
 
use serde::{Serialize, Deserialize};
use chrono::{DateTime, Utc};
use uuid::Uuid;
 
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Default)]
#[serde(rename_all = "camelCase")]
pub struct UserProfile {
    pub bio: String,
    pub location: String,
    pub github: String,
}
 
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Default)]
#[serde(rename_all = "camelCase")]
pub struct UserStats {
    pub stars_count: i64,
    pub rating: f64,
}
 
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Default)]
#[serde(rename_all = "camelCase")]
pub struct User {
    pub id: i64,
    pub user_name: String,
    pub email: String,
    pub is_verified: bool,
    pub roles: Vec<String>,
    pub created_at: DateTime<Utc>,
    pub profile_id: Uuid,
    pub profile: UserProfile,
    pub stats: UserStats,
}

100% Zero-Egress Privacy

Never paste production API tokens or enterprise customer data into ad-heavy remote servers. Nazamos runs 100% locally in your browser with zero network requests.

Compile-Ready Rust Code

Handles all 39 Rust reserved keywords (`type`, `match`, `ref`), integer vs float precision, and recursive nested structs with idiomatic PascalCase naming.

Modern Backend Support

First-class support for chrono::DateTime<Utc>, uuid::Uuid, and seamless integration with web frameworks like Axum, Actix-web, and reqwest.

Developer Reference & Cheat Sheet

JSON to Rust Serde: Type System Mapping

How Nazamos maps dynamic JSON types into Rust's strict compile-time type system:

JSON Data TypeInferred Rust TypeSerde Attribute / Notes
String ("hello")StringStandard heap-allocated UTF-8 string
Integer (42, -100)i6464-bit signed integer (prevents overflow on IDs & timestamps)
Float (19.99, 3.14)f64Double-precision IEEE 754 floating point
Boolean (true / false)boolStandard 1-byte boolean
ISO-8601 Date ("2026-09-09T...")DateTime<Utc>Requires `chrono` crate with serde feature enabled
UUID ("a0eebc99-...")UuidRequires `uuid` crate with serde feature enabled
Null / Missing FieldOption<T>`#[serde(skip_serializing_if = "Option::is_none")]`
Array ([1, 2, 3])Vec<T>Dynamically sized vector with homogeneous items
Nested Object (&lbrace;"sub": &lbrace;…&rbrace;&rbrace;)ChildStructExtracted into a separate named PascalCase struct
Keyword ("type", "match")r#type / r#matchSafe Rust raw identifier with `#[serde(rename = "...")]`

1. Add Dependencies to Cargo.toml

Copy and paste these dependencies into your Rust project's Cargo.toml file:

[dependencies]
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
chrono = { version = "0.4", features = ["serde"] }  # Optional: For DateTime<Utc>
uuid = { version = "1.0", features = ["serde", "v4"] }  # Optional: For Uuid

2. Deserializing in Production (Axum & serde_json)

Example showing how to parse JSON strings and use generated structs inside an Axum API handler:

use serde::{Deserialize, Serialize};

// Generated struct from Nazamos
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct User {
    pub id: i64,
    pub user_name: String,
    pub is_verified: bool,
}

// 1. Direct parsing from a string
fn parse_example() -> Result<(), Box<dyn std::error::Error>> {
    let json_data = r#"{"id": 1042, "userName": "alex", "isVerified": true}"#;
    let user: User = serde_json::from_str(json_data)?;
    println!("Parsed User: {:#?}", user);
    Ok(())
}

// 2. Axum API handler example
// async fn create_user(axum::Json(payload): axum::Json<User>) -> axum::response::Json<User> {
//     println!("Received user: {:?}", payload);
//     axum::Json(payload)
// }

JSON to Rust Serde Conversion FAQs

Paste any valid JSON payload or array into the editor. The Nazamos parser analyzes your data structure, detects types (scalars, arrays, nested objects, ISO timestamps, and UUIDs), and generates idiomatic Rust structs equipped with `#[derive(Serialize, Deserialize, ...)]` and Serde field attributes.