Code generator tool
JSON to Rust, TypeScript & C++
Paste any JSON object or array to generate strongly typed Rust serde structs, TypeScript interfaces, or C++ structs locally in your browser.
INPUT JSON100% local in browser
models.rs
// Paste JSON on the left (or click 'Load Sample') to generate Rust serde structs.What This Converter Handles Automatically
Objects in the same array are merged into one type, so a key that only some items have becomes optional instead of creating a second type. Each language then gets its own conventions:
- Rust (
serde): converts camelCase keys tosnake_casewith#[serde(rename = "...")], escapes keywords (r#type), and wraps nullable or sometimes-missing fields inOption<T>. The JSON to Rust guide shows how to parse JSON into the structs with serde_json. - TypeScript: generates
export interfacedeclarations, with?for keys some objects lack and| nullfor nulls. The JSON to TypeScript guide covers typing and checking fetch responses. - C++: declares child structs before the structs that use them and maps arrays and nullable fields to
std::vectorandstd::optional. The JSON to C++ guide shows how to fill the structs with nlohmann/json.