JSON To Rust Serde
Generate Rust Serde structs with Serialize and Deserialize derives from JSON sample payloads.
Generate Rust Serde structs from JSON payloads
Rust services often deserialize JSON from HTTP APIs, queues, and config files. Hand-writing
nested structs with Serde derives for every payload sample is repetitive and drifts when
fields change. This generator inspects your JSON sample and emits Rust struct definitions
with Serialize and Deserialize attributes.
What this tool does
Paste JSON in the input panel. The converter walks nested objects and arrays, infers field types, and outputs Serde-ready struct definitions. You can set the root struct name and choose between camelCase and snake_case field naming before copying the result.
Configuration options
- Root Struct Name: Rename the top-level struct generated from your JSON sample.
- Field Naming Style: Switch between camelCase and snake_case property names.
Common use cases
- Bootstrap API response models for Axum, Actix, or tonic services.
- Create starter structs before wiring JSON parsing in CLI tools.
- Document expected payload shapes for backend teams.
- Compare inferred models against OpenAPI or JSON Schema contracts.
Related tools
Need Kotlin or Go models instead? Try the JSON to Kotlin or JSON to Go POJO Generator. For runtime TypeScript codecs, use the JSON to io-ts tool.
Frequently Asked Questions
Does my JSON leave the browser?
No. Conversion runs entirely in your browser. Your JSON is never uploaded to a server, which makes the tool safe for internal API samples and production-like fixtures.
Do I need Serde in my Rust project?
Yes. Add serde with derive support to your Cargo.toml,
paste the generated structs into a Rust module, and use them with your JSON
serializer of choice.
Which field naming style should I use?
Use snake_case when matching typical Rust API conventions and serde defaults for JSON with snake_case keys. Use camelCase when your JSON payloads use camelCase field names and you want struct fields to match directly.
Are optional fields detected?
The generator infers types from the provided sample. Fields missing from the sample will not appear in output. Provide representative samples or extend generated structs manually for nullable or optional fields.