Youtilities

JSON to Rust Struct

Generate Rust structs with serde derives and Option fields from any JSON.

Runs in your browser. Nothing is uploaded.

Input

Waiting for JSON

Rust
Rust types appear here.

What this does

Paste JSON and get Rust structs deriving Serialize and Deserialize for serde. Nested objects become their own structs; arrays of objects are merged into one struct.

Option and defaults

A value that is sometimes null becomes Option<T>. A key missing from some items also gets #[serde(default)] so decoding does not fail, and is skipped when serializing None. Whole numbers are i64, decimals f64, unknown values serde_json::Value.

Names

Fields are snake_case; when that differs from the JSON key (firstName → first_name) a #[serde(rename)] keeps the original. Reserved words become raw identifiers such as r#type. Two objects with the same shape share one struct.

All