JSON to Rust

Convert JSON to Rust struct.

Convert JSON to Rust struct.

This tool is designed to provide a seamless experience for developers by handling complex operations directly in your browser with maximum speed and security.

100% Private
Instant Results
Customizable
Offline Ready
Dev-Friendly
Easy Export

This tool transforms JSON into clean, idiomatic Rust structs with Serde implementation for seamless serialization and deserialization. It handles various Rust data types, including support for nested objects and optional fields (Option<T>), making it easy to work with JSON in Rust applications. It is an essential tool for developers working on performance-critical applications, system programming, or web services with libraries like Actix, Rocket, or Axum, where safety and efficiency are paramount. By generating the necessary structs and Serde annotations, it ensures that your Rust models always match your JSON schema, providing a robust and performant foundation for your projects.

Paste your JSON to generate Rust structs with `serde` derive macros. It handles nested objects by creating multiple structs.

Rust is known for its strict type system and safety features, and manually creating structs for complex JSON responses can be a slow and error-prone process. This tool handles the repetitive task of mapping data types and generating correctly formatted Rust code, allowing you to focus on your application's core logic while maintaining total type safety and performance.

Example Input

{
  "id": 1,
  "name": "John Doe",
  "email": "john@example.com",
  "isActive": true,
  "tags": ["admin", "dev"],
  "profile": {
    "bio": "Software Engineer",
    "skills": ["Go", "React", "TypeScript"]
  }
}

Example Output

#[derive(Serialize, Deserialize)]
struct User {
    id: i32,
    name: String,
    email: String,
    is_active: bool,
}

Serde Dependency

Fix: The generated code requires the `serde` and `serde_json` crates. Add them to your `Cargo.toml`.

Does it handle Option types?

Yes, fields that are null in the JSON are automatically mapped to `Option<T>` in Rust.