๐Ÿฆ€ JSON to Rust Struct Generator

JSON โ†’ Rust Struct ยท Serde Support ยท Option Types ยท Nested Structures

๐Ÿ“ฅ Input JSON
๐Ÿ’ป Generated Rust Code
// Enter JSON and click "Generate Rust Code"

โ“ Frequently Asked Questions

What dependencies are needed?โ–ผ

Add to Cargo.toml: serde = { version = "1", features = ["derive"] } and serde_json = "1". The generated #[derive(Serialize, Deserialize)] annotations work directly with these crates.

Is my JSON data secure?โ–ผ

Yes. All processing is done locally in your browser. No data is uploaded to any server. You can safely process sensitive data like API keys or private configuration.

camelCase vs snake_case?โ–ผ

Enable snake_case to generate Rust-style field names (e.g., user_name). Enable camelCase to add #[serde(rename_all = "camelCase")], which maps between Rust snake_case fields and JSON camelCase keys automatically during serialization/deserialization.

How are nullable fields handled?โ–ผ

Fields with null JSON values are automatically mapped to Option<T>. You can also enable "Make all fields Option" to make every field nullable. Using #[serde(default)] together with Option allows missing fields to deserialize as None.

๐Ÿ’ก All processing is done locally in your browser. Generated Rust code is ready for production.