One document, or several samples as JSON Lines.
Options for Rust

Convert JSON to Rust structs

Paste a JSON sample and get Rust structs deriving Deserialize (and Serialize if you like): String, i64, f64, bool, Vec<T>, nested structs, Option<T> for nullable or optional fields with #[serde(default)], and #[serde(rename = "...")] wherever a key isn't a snake_case identifier. Integers past i64 become u64 or i128; values of no single type become serde_json::Value.

The generated structs compile in the tests. It runs entirely in your browser.

Need a different language? See all JSON-to-code converters.

JSON to Rust Struct Converter (serde) — frequently asked questions

What do I need to use the output?
Add serde with the derive feature, and serde_json if the output mentions serde_json::Value. Then serde_json::from_str::<Root>(json) reads your data.
What if some records have fields that others don't?
Every item of every array and every sample is read, not just the first. A field missing from some records comes out optional, a field holding two kinds of value becomes a union (or the language's any-value type), null beside a value makes it nullable, and a list of records at the top level gets an item type plus an alias for the list. Paste several samples as JSON Lines, one per line, and they're merged the same way.
Is my JSON uploaded anywhere?
No. Parsing and code generation run entirely in your browser with JavaScript — your JSON never leaves your device, so it's safe to paste API responses and other sensitive payloads. It's free with no sign-up.

Spotted a bug or have a suggestion?

Found something broken, have an idea, or just want to say thanks about any of our tools? Every message reaches a real person.