Deserialising an API in Rust
Paste a sample response and get serde-ready structs to deserialize into with serde_json.
Generate Rust structs from a JSON sample in your browser, deriving Serialize and Deserialize.
Maintained by Roshan.
Converts json sample to rust struct in this tab, with nothing sent anywhere.
Find related browser-local tools for nearby tasks without starting another search.
Browse all generatorsRust's approach to JSON runs through serde, and that means declaring a struct that mirrors the data and derives Serialize and Deserialize. Writing those by hand for a real response is exacting work - every field typed, every name in snake_case, the derives remembered. Generating from a sample does it in one step: paste the JSON, get the structs with their serde derives already attached. This infers the shape recursively, gives nested objects their own structs, and uses sensible Rust types - String, f64, bool, Vec for arrays - so the result compiles against serde with minimal editing. As with the other generators it types what the sample proves and leaves genuine optionality, which in Rust means Option, for you to add where the data allows nulls.
Paste a sample response and get serde-ready structs to deserialize into with serde_json.
Generate the structs, then narrow numeric types and add Option where fields may be absent.
Yes. Every struct derives Serialize and Deserialize, ready for serde_json.
JSON has one number type, so f64 is the safe default. Narrow to an integer type where the data allows.
Option is not added automatically, since a sample cannot prove it. Wrap fields in Option where nulls occur.
Yes. Each becomes its own struct referenced by the parent.
Generate Go structs from a JSON sample in your browser, complete with json struct tags.
Generate TypeScript interfaces from a JSON sample in your browser. Nested objects become their own interfaces.
Generate a JSON Schema from a sample document in your browser, inferring types and required fields.