Email me

Free tool · no sign-up · runs in your browser

JSON to Rust struct.

Paste a JSON response, get serde structs ready to paste into your crate. Every item of an array is merged, not just the first one, so a key that is sometimes missing or null becomes Option up front instead of a deserialize error in production. camelCase keys get renamed, keywords like type are handled, and nested objects get their own structs. Your JSON is never uploaded.

Your JSON

Paste an API response or a config file. Parsing runs on this page.

Derives

Options

RustCode ↓

What the generator does

FAQ

How do I parse JSON into a struct in Rust?

Add serde (with the derive feature) and serde_json to Cargo.toml, paste your JSON above, copy the structs, then call let data: Root = serde_json::from_str(&text)?;. To read from a reqwest response, use resp.json::<Root>().await? (reqwest's json feature).

How do I handle a field that is sometimes missing?

Make it Option<T>. serde fills a missing Option field with None. This tool does it automatically when a key is missing from some items of an array or is null.

How do I map camelCase JSON keys to snake_case Rust fields?

Put #[serde(rename_all = "camelCase")] on the struct, or #[serde(rename = "userName")] on a single field. The generator picks the shorter of the two for each struct.

What if my JSON has a key named type?

type is a Rust keyword, so the field is written as r#type. serde strips the r# prefix, so it still matches the JSON key type.

Should I use f64 for money?

For display, f64 is fine. For arithmetic on money, parse into an integer number of cents or a decimal crate such as rust_decimal, because binary floats cannot represent most decimal amounts exactly.

Is my JSON sent to a server?

No. Parsing and code generation run in your browser. Nothing you paste leaves the page.

Parsing model output into these structs?

LLMs wrap JSON in prose and code fences, leave trailing commas and cut replies off. Our free LLM JSON repair tool fixes the reply first, so serde_json::from_str gets valid JSON.

Open LLM JSON repair →

Keep going

Get the receipts by email.

What my AI agents tried this week, with the real numbers: what worked, what flopped, what made money. One email when there is something worth reading.

No spam, never sold. Every email has a one-click unsubscribe.

Popular in the shop

All 124 tools →

Browse: Bundles and kitsHome, family and schoolMoney and businessAI toolsSports and fitnessMaking and hobbiesFood and drinkIndie dev and launchTrading and quant

Free: Landing page teardown iPhone app cost calculator LLM API cost calculator Paid online: $49 Launch Check App builds Articles FAQ