JSON to Rust

Convert JSON to Rust structs online. Serde-ready structs with #[derive(Serialize, Deserialize)], Option<T> for nullable fields, and automatic camelCase renaming.

Generated code will appear here...

Everything runs locally in your browser. Your JSON is never uploaded or stored.

What is a JSON to Rust converter?

A JSON to Rust converter turns a raw JSON sample into serde-annotated Rust structs. Paste an API payload and get types you can drop straight into a Rust project next to serde_json. Everything runs in your browser.

How to generate Rust structs from JSON

Paste your JSON and the structs appear live. Press Copy and add them to your project — pair the output with serde and serde_json derives already included in the code.

Type mapping

Whole numbers map to i64, fractional numbers to f64, arrays to Vec<T>, and objects with non-identifier keys to HashMap<String, T>. Values of unknown or mixed shape become serde_json::Value so nothing breaks at runtime.

Naming and serde attributes

Fields are named in snake_case per Rust style. When every key is already camelCase, a single #[serde(rename_all = "camelCase")] is emitted; otherwise individual fields get #[serde(rename)]. Optional and null fields use Option<T>.

Frequently Asked Questions

How do I convert JSON to Rust structs?+
Paste a JSON object or array into the input box. Serde-ready structs are generated instantly: nested objects become their own pub structs, and everything is copyable with one click.
How are JSON types mapped to Rust?+
Strings become String, integers i64, decimals f64, booleans bool, arrays Vec<T>, string-keyed maps HashMap<String, T>, and unknown or mixed shapes fall back to serde_json::Value. Nested objects become separate structs named after their key.
What does #[serde(rename_all = "camelCase")] do?+
It tells serde to accept and emit camelCase keys while your struct fields stay snake_case per Rust conventions. When only some fields need renaming, a per-field #[serde(rename = "...")] is used instead, and missing or null values become Option<T>.
Is my JSON uploaded to a server?+
No. All conversion runs locally in your browser — nothing is sent, stored, or logged.

Related Tools

JSON to Rust — free online json to rust, json to rust struct, rust serde struct generator, json to serde, convert json to rust, rust struct from json, json to rust online, generate rust structs, serde json struct, rust json model generator. No signup required. Works in your browser.