Skip to main content

JSON to Rust

New

Generate Rust structs with serde derive attributes from JSON data.

convertrustserde
Read the guide
Shortcuts:⌘ KSearch
Field names are normalized to snake_case.
Serde rename attributes are added only when required.

Frequently Asked Questions

Why were my field names converted to snake_case?

This generator normalizes Rust field names to snake_case. It only adds #[serde(rename = "...")] when the normalized field name no longer matches the original JSON key.

When do fields become Option<T>?

Only when null appears in the sampled data for that field or merged array item type. Missing keys by themselves do not produce Option<T>.

What happens with mixed values or empty arrays?

Mixed or unknown shapes fall back to serde_json::Value. Empty arrays become Vec<serde_json::Value>.

Does it support top-level arrays?

Yes. If the root is not an object, the output becomes a pub type alias instead of a struct.

What derives are included on generated structs?

Every struct gets #[derive(Serialize, Deserialize, Debug)].

Related Tools