One-click convert JSON data to Rust struct definitions with serde tags and Option types
Zero Dependencies · Works OfflineThe JSON to Rust Struct Converter is a free online developer tool that instantly converts JSON data into Rust struct definitions. It automatically identifies JSON field types and maps them to Rust types, supporting nested object struct generation, serde serialization tags, and Option type handling. Perfect for Rust developers who need to quickly generate type definitions from API responses or configuration files, combined with serde_json for automatic serialization/deserialization. All conversion happens locally in your browser — no data is ever uploaded to a server.
1. Paste your JSON data into the input area, or click "Load Example" to try it quickly.
2. Set the struct name and conversion options: serde tags, Option types, visibility, etc.
3. Click "Convert" or use Ctrl+Enter to execute.
4. View the generated Rust struct code in the result area below.
5. Click "Copy Code" to copy to clipboard, or download as a .rs file.
When building backends with Axum/Actix-web, quickly generate Rust structs from JSON request/response schemas with serde for automatic serialization.
Generate config struct definitions from JSON config files in Rust projects, ensuring type safety.
Generate structs from JSON API responses for type-safe HTTP clients with reqwest+serde.
Generate Rust structs from JavaScript JSON data for type-safe cross-language communication in WebAssembly.
serde is the most popular serialization framework in the Rust ecosystem, with serde_json as its JSON implementation. #[derive(Serialize, Deserialize)] enables automatic JSON encoding/decoding for structs. When Rust field names differ from JSON keys (e.g., Rust uses camelCase isVip while JSON uses is_vip), #[serde(rename="is_vip")] provides the mapping. Option
Yes. Nested objects are automatically generated as separate Rust struct definitions.
With "Option types" enabled, null fields generate Option
Yes. Generates #[serde(rename)] and #[serde(default)] tags.
No. All processing happens locally in your browser. Your data never leaves your device.
Add serde = {version="1",features=["derive"]} and serde_json = "1" to Cargo.toml.
Yes. Add serde dependencies and the generated code compiles directly.