JSON to Rust Struct — Free Online (serde)
Generate Rust structs with serde Serialize/Deserialize derives from any JSON sample. Snake_case field names, serde rename tags.
Generate Rust structs with serde Serialize / Deserialize derives from any JSON sample. Each unique object shape becomes its own struct, snake_case field names with serde renames preserving the original keys, and idiomatic Rust types (i64, f64, bool, String, Vec<T>).
Need TypeScript instead? JSON to TypeScript. Go? JSON to Go. Python? JSON to Python.
How to Generate Rust Structs from JSON
Paste a JSON sample
Drop a representative JSON value into the editor — API response, config, mock fixture.
Click Convert to Rust
PDFFlare emits Rust structs with #[derive(Debug, Serialize, Deserialize)] and snake_case field names.
Drop into your Rust project
Paste into a .rs file in a project that depends on serde + serde_json.
When Do You Need JSON to Rust?
Typing an external API: You're building a Rust client for a service that ships JSON. Generate the response types straight from a sample.
Migration projects: Porting a Node or Python service to Rust? Use real production payloads to seed the type definitions.
Webhook handlers: Stripe, GitHub, etc. publish webhook payloads as JSON examples. Generate Rust types and wire them into a serde-powered handler.
Embedded / WASM: Rust's strong typing pays off when memory matters. Get accurate types from JSON before optimising further.
Why Use PDFFlare for JSON to Rust?
serde Out-of-the-Box
Every struct derives Serialize + Deserialize, with rename attributes preserving the original JSON keys.
Idiomatic Rust
snake_case field names, pub fields, idiomatic numeric types — fits straight into a Rust crate.
100% Browser-Based
Sample data stays on your device.
No Signup Required
No account, no rate limits.
Frequently Asked Questions About JSON to Rust
Yes. Every struct derives Serialize + Deserialize. Field names that aren't valid snake_case get a #[serde(rename = "...")] attribute so they decode incoming JSON correctly.
Each unique object shape becomes its own struct. Names are inferred from property names (singularized for arrays of objects).
Whole-number values become i64; decimals become f64. JSON treats both as 'number' but the converter inspects each value.
Vec<serde_json::Value> for mixed arrays. If you want a tighter type, refine after generation — Rust's enum + serde tag attribute can express discriminated unions cleanly.
Yes. JSON often uses camelCase; Rust prefers snake_case. Each field is converted, with a serde rename attribute preserving the original key for serialization.
Currently every field is required. Nullable handling is on the roadmap — for now, wrap the type in Option<T> manually for any field your domain treats as optional.
No. Conversion runs entirely in your browser.
serde and serde_json. Add to Cargo.toml: serde = { version = "1", features = ["derive"] } and serde_json = "1".