JSON to Rust struct
serde is exact by design: a struct field the JSON does not carry is a hard deserialization error, not a quiet default. That makes getting the shape right up front worth automating — paste a payload and get structs with #[derive(Serialize, Deserialize)], correct nesting, Vec<T> for arrays and integer/float types picked from the values seen.
Fields that can be null or absent become Option<T>, so Deserialize succeeds on the responses your API actually sends — merge two or three real samples and the Options land exactly where the data says they should, not where you guessed.
Keys that are not idiomatic Rust (camelCase, kebab-case, reserved words like type) get #[serde(rename = "…")] attributes, keeping your field names clean while the wire format stays untouched.
How JSON type inference works
The generator reads your JSON and builds the strictest type that fits every value it saw: objects become interfaces, structs or classes; arrays become typed lists; a value that appears as both a number and a string becomes a union. Repeated string values (like "active" / "inactive") can be promoted to an enum, and ISO 8601 timestamps or UUIDs can map to your language's date and UUID types — both are toggles above.
Why add multiple samples?
One API response rarely shows every field — optional fields are missing, nullable fields happen to be set. Add two or three real responses with Add sample and they merge into a single type: a field present in every sample stays required, and a field that only some samples carry becomes optional. More samples always produce a more honest type.
Nullable is not optional
A field that appears as null in a sample is nullable — it is always present, but its value may be null (string | null). A field that is missing from some samples is optional — it may not exist at all (field?: string). Serializers treat the two very differently, which is why the generator keeps them distinct instead of collapsing both to "maybe".
JSON Schema in, types out
Already have a JSON Schema? Switch the input to JSON Schema and the types are derived from the schema's declared properties, required list and formats instead of being inferred from samples — or pick the JSON Schema output target to go the other way and generate a schema from samples.
FAQ
Does my JSON leave the browser?
No — generation happens on your device. Paste real payloads, including ones with credentials, without them going anywhere.
When does a field become Option<T>?
When any pasted sample shows it as null or omits it entirely. serde fails deserialization on a missing non-Option field, so merging several real samples is the difference between code that compiles and code that runs.
How are JSON keys that are not valid Rust handled?
With #[serde(rename = "original-key")] on the field — your struct keeps an idiomatic snake_case name while serialization still reads and writes the original key.
What about mixed-type values?
A value that appears as, say, both a number and a string generates an untagged enum so either form deserializes — stricter than falling back to serde_json::Value, and it round-trips.