JSON to Rust

Generate Rust structs with serde derives and Option types from JSON.

Generate Rust structs

Result: —
Structs derive Debug, Serialize and Deserialize, so keep the serde and serde_json crates in your project.

How to use the JSON to Rust

  1. Paste a JSON sample into the input box.
  2. Set the name of the root struct.
  3. Click Generate structs and copy the Rust code.

Features

Advertisement

Frequently Asked Questions

Common questions about the free online json to rust.

Paste a JSON sample, set the root struct name and click Generate structs. Every object shape becomes a struct with typed public fields.
Every struct gets the derive attribute for Debug, Serialize and Deserialize, so it works with serde without further edits.
A field that can be null becomes an Option type, while fields with mixed or unknown types use serde_json::Value so any data still fits.
Arrays become Vec types with the matching element type, and an array that is missing from some entries becomes an Option around the Vec.
Field names use snake case, and a serde rename attribute is added whenever the original JSON key would not match the Rust name.
Keys such as type or match become identifiers with a trailing underscore, while the rename attribute keeps the original JSON key working.
No. The structs are generated inside your browser, so nothing is uploaded, logged or stored anywhere.
Invalid JSON, or a sample that is not an object or an array, produces a clear error message instead of code.

Last updated: October 10, 2026