ToolBuddy
In Browser

JSON to Rust

Infer Rust structs from a JSON sample. Nested objects become named structs with serde renames. Keys missing from some objects in an array are optional. Conversion stays in the tab.

Runs in your browser. Nothing is uploaded.

0 characters · 0 lines

0 characters · 0 lines

About this tool

Infer Rust structs from a JSON sample. Objects become named structs with serde Serialize and Deserialize. Camel-case keys become snake_case fields with a rename. Keys missing from some objects in an array, and a JSON null next to a concrete value, become Option. Whole numbers stay i64. Other numbers become f64.

How to use: paste JSON, copy the structs. A root array of objects is type Root = Vec<RootItem>. Empty objects become HashMap<String, serde_json::Value> and empty arrays become Vec<serde_json::Value>. This is a starting point. It does not add methods, enums, or validation.

Example: {"id":1,"name":"Ada","address":{"city":"London"}} yields struct Root and struct Address. The snippet expects the serde and serde_json crates. Related: JSON to Go for structs, JSON to TypeScript for interfaces, JSON to Python for dataclasses.

The sample stays in the tab. Nothing is uploaded. After the page loads, conversion works offline.

FAQ

Related Convert tools