JSON → Rust structs (serde)
ClientPaste JSON to get Serialize / Deserialize structs with per-field rename attributes—add serde and serde_json in your crate.
Review before compiling
The generated code is deliberately simple. Before pasting it into a crate, review ownership, Option fields, enum candidates, date and decimal strings, and any serde attributes your API requires.
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.
Nearby workflows on Toolcore
- JSON formatter — when the sample still needs strict parse before you trust the inference.
- JSON → Go — to mirror struct tags across two backend languages.
- Compare JSON — after you change the sample and want to see structural drift.
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.
- Turn a small API response into owned structs before deciding whether borrowing or Cow is worth the complexity.
- Identify places where a JSON object should become a Rust enum, newtype, or hand-written Deserialize implementation.
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.
Assuming null always means Option
Null, missing fields, and explicit empty values can have different meanings. Review Option fields against the real contract.
Skipping date and decimal types
The scaffold cannot know whether strings are dates or whether numbers need Decimal. Add chrono, time, rust_decimal, or custom parsing where required.
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.
Will it generate enums from sample values?
No. It focuses on struct scaffolding from one sample. Tagged, untagged, and externally tagged enums should be modeled intentionally.
Can I use the output directly with reqwest?
Usually after review. Add serde dependencies, check ownership and Option fields, and write tests with real response samples before using it in a client.
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 → Nim types
ClientNim object types from sample JSON—snake_case fields, seq for arrays, browser-side.
JSON → Haskell records
ClientHaskell records with aeson Generic FromJSON/ToJSON from sample JSON—browser-side scaffolding.
YAML ↔ JSON
ClientYAML to JSON and JSON to YAML online—bidirectional converter, format either side in the browser.