JSON to Rust

Paste JSON and instantly get matching Rust struct definitions with serde derives, nested structs, and Vec types.

JSON Input

Rust Structs

Nested objects become their own named struct, since Rust has no anonymous struct syntax.

Copied!

Summary

Paste JSON and instantly get matching Rust struct definitions with serde derives, nested structs, and Vec types.

How it works

  1. Paste JSON into the input box, or click "Load Sample" to try it with example data.
  2. Set a root struct name for the top-level type.
  3. The Rust struct definitions render on the right as you type.
  4. Nested objects become separate named structs; arrays of objects merge their fields into one struct.
  5. Toggle "Derive Clone" if your code needs to clone the generated structs.
  6. Click "Copy Rust Code" to copy the generated code to your clipboard.

Use cases

  • Bootstrap Rust structs for a REST API client from a sample response.
  • Type a webhook payload before writing the handler.
  • Generate structs from third-party API documentation JSON.
  • Check how serde will map a JSON shape before writing code by hand.
  • Speed up prototyping Rust services that consume external JSON.

Frequently Asked Questions

Last updated: 2026-07-24 · Reviewed by Nham Vu