IQ
PayloadIQ
PayloadIQ Utilities

JSON to Rust

Paste a JSON sample and get idiomatic Rust structs back — serde derives, snake_case fields with #[serde(rename)], nested structs, Vec and Option. It all runs in your browser.

Rust structs appear here.

Runs in your browser. Your input is not uploaded to PayloadIQ.

JSON to Rust turns a JSON sample into idiomatic Rust structs you can paste straight into a crate. Every struct derives Debug, Serialize, Deserialize, fields are emitted in snake_case, and when a JSON key isn't already snake_case a #[serde(rename = "…")] keeps (de)serialization lossless. Nested objects become their own structs, arrays become Vec<T>, and a key missing from some elements becomes Option<T>. Everything runs locally in your browser, so a real API response never leaves your machine.

serde-ready, idiomatic Rust

Whole numbers map to i64 and decimals to f64; the output is ready to drop into a project that uses serde and serde_json. You can rename the top-level struct with the Root-name field.

Inference is sample-driven

The generator can only see what you give it, so paste the richest payload you have — for lists of objects it merges the keys across elements and marks any that are missing as Option. Want types in another language (TypeScript, Zod, Go, Python) or a full typed client and schema report from the same payload? Open it in the PayloadIQ playground.

FAQ

Is my JSON uploaded?
No. The JSON is parsed and converted entirely in your browser with JavaScript — it never leaves your device. That makes it safe for real API responses, auth payloads, and anything internal.
How are JSON keys mapped to Rust fields?
Fields are emitted in idiomatic snake_case. When the original JSON key differs (e.g. camelCase userName), a #[serde(rename = "userName")] attribute is added so (de)serialization round-trips to exactly the keys in your payload.
What about types, nesting and optional fields?
Whole numbers become i64 and decimals f64; booleans bool; strings String; arrays Vec<T>. Nested objects become their own structs, and a key present in only some elements of an array of objects becomes Option<T>. Every struct derives Debug, Serialize and Deserialize.
How complete is the inference?
It is only as complete as the sample you paste, so use the richest, most representative payload you have. The generator can't know a field is sometimes null or sometimes a float unless the sample shows it — so review Option and numeric types for fields that may vary.

Related utilities

JSON to GoJSON to TypeScriptJSON to ZodJSON Formatter / ValidatorJSON VisualizerJSON MinifierJSON DiffJSON to CSV
Open PayloadIQ Playground