JSON → Rust structs (serde)
ClientPaste JSON to get Serialize / Deserialize structs with per-field rename attributes—add serde and serde_json in your crate.
Learn more: JSON and Rust
Emit `struct` types with `serde` derives and per-field `rename` attributes—aligned with `serde_json` and typical REST payloads.
Serde
Add `serde` and `serde_json` to your crate. Fields use idiomatic snake_case in Rust with `#[serde(rename = "…")]` for the JSON wire shape. Prefer integers over `f64` when your API guarantees whole numbers. Values that are only `null` in the sample map to `serde_json::Value`—narrow to `Option<T>` when you know the real type.
JSON → Rust
?
Parses JSON in your browser and emits classes inferred from the sample shape. Nested objects become nested types; arrays use the first element only to guess item shape. Nothing is uploaded.
Field names are idiomatic snake_case with #[serde(rename)] for JSON keys; switch f64 to i64 when appropriate.
Common use cases
- Bootstrap serde structs for REST and config JSON before adding lifetimes and custom deserializers.
- Align rename attributes with snake_case APIs while keeping idiomatic Rust field names.
- Share a first-pass model in RFCs or internal docs.
Common mistakes to avoid
Deriving Deserialize on types that need custom logic
Enums with externally tagged variants, tagged unions, or untagged shapes may need serde annotations or manual impls.
Using owned String everywhere
Borrowed data with &str or Cow can reduce allocations—adjust after profiling.
FAQ
Is Rust code generated locally?
Yes. JSON stays in your browser during generation.
Does this add serde_with or chrono features?
It emits basic derives. Add crates and attributes for dates, enums, and newtypes as your API requires.
More tools
Related utilities you can open in another tab—mostly client-side.
JSON → Python TypedDict
ClientTypedDict scaffolding from sample JSON—nested shapes inferred in the browser.
JSON → Go structs
ClientGo structs with json tags from sample JSON—inferred in the browser.
JSON → Swift structs (Codable)
ClientSwift structs with Codable and CodingKeys from sample JSON—local only.
YAML ↔ JSON
ClientYAML to JSON and JSON to YAML online—format, validate, convert locally.