D/F DevFormat.tools
Type Generators Runs locally

JSON → Rust Struct converter

Generate serde-ready Rust structs from JSON locally, with nested objects, vectors, and renamed fields.

Paste your source, then convert it locally.

Private · browser only

Your data stays in this browser. Nothing is uploaded.

Conversion directions

Direction 01

JSON to Rust Struct

Generate serde-ready Rust structs from JSON.

About this converter

Generating serde-ready Rust structs

Paste a JSON object and the converter emits Rust structs with serde derive attributes and rename rules that keep the original JSON keys. The output is ready for serde_json::from_str, so you can deserialize API payloads into strongly typed values with compile-time guarantees.

Optional fields become Option<T>, arrays become Vec<T>, and nested objects become referenced structs, matching how serde models real-world data.

Rename rules and field mapping

serde's rename_all = "camelCase" or "snake_case" rules are applied so that idiomatic JSON keys map to idiomatic Rust field names without per-field attributes. This keeps the generated code concise even for large payloads.

Integrating with a Rust project

Add serde and serde_json to Cargo.toml, paste the structs into a module, and call serde_json::from_str::<RootType>(&payload). The compiler then verifies every field access, eliminating a whole class of runtime key errors.

Frequently asked questions

Does the output work with serde?

Yes. Generated structs derive Serialize and Deserialize and add rename attributes when required.

What type is used for JSON numbers?

Integers use i64 and decimal values use f64.

Does it add serde derive attributes?

Yes. The output includes serde derive macros and rename rules so the structs deserialize directly with serde_json::from_str.

How are optional fields handled?

Fields that can be null become Option<T>, and arrays become Vec<T>, matching how serde models real-world data.

Does it use rename rules?

Yes. serde rename_all rules like camelCase or snake_case are applied so JSON keys map to idiomatic Rust field names without per-field attributes.

Can I use it with serde_json?

Yes. Add serde and serde_json to Cargo.toml and call serde_json::from_str on the generated root type.