Free browser-based converter
JSON to Rust Struct Converter
Convert sample JSON into Rust structs when you need a fast starting point for API clients, config loaders, or internal tools. Typify infers nested structs, Vec<T> arrays, and Option<T> fields for nullable values automatically.
The generated output is geared toward common serde workflows, with derive macros and public fields that you can paste into Rust services, CLIs, or data-processing code with minimal cleanup.
JSON input
280 / 50 KB
Rust structs
use serde::{Deserialize, Serialize}; #[derive(Debug, Serialize, Deserialize)] pub struct Root { pub service: Service, } #[derive(Debug, Serialize, Deserialize)] pub struct Service { pub id: f64, pub name: String, pub healthy: bool, pub owners: Vec<Owner>, pub regions: Vec<String>, } #[derive(Debug, Serialize, Deserialize)] pub struct Owner { pub name: String, pub email: Option<String>, }
Example
Start with the sample below, then replace it with your own data to generate output instantly.
Input JSON
{
"service": {
"id": 17,
"name": "typify",
"healthy": true,
"owners": [
{
"name": "Ada",
"email": "ada@example.com"
},
{
"name": "Lin",
"email": null
}
],
"regions": ["us-east-1", "eu-west-1"]
}
}Rust output
use serde::{Deserialize, Serialize};
#[derive(Debug, Serialize, Deserialize)]
pub struct Root {
pub service: Service,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct Service {
pub id: f64,
pub name: String,
pub healthy: bool,
pub owners: Vec<Owner>,
pub regions: Vec<String>,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct Owner {
pub name: String,
pub email: Option<String>,
}