JSON to Java Converter
Convert JSON to Java POJO classes for Java development
JSON Input
Java Output
What Is JSON to Rust?
Rust uses structs with Serde for JSON serialization. This tool generates Rust structs with #[derive(Deserialize, Serialize)] so you can parse API responses with serde_json. The JSON specification defines the input format.
Conversion runs in your browser. Set the struct name in the config. Nothing is sent to a server. Add serde and serde_json to your Cargo.toml to use the generated structs.
How to Use This Tool
Paste or Upload JSON
Paste your JSON into the left editor or upload a file. Use the config panel to set the root Struct Name. The more representative your sample, the better the generated structure.
Review the Generated Structs
The right panel shows Rust structs with Serde derives. Use serde_json::from_str::<YourType>(json) to parse. Add #[serde(rename = "json_key")] if JSON keys differ from field names. Add Option<T> for optional fields. Validate JSON first with JSON Validator if needed.
Copy or Download
Use Copy or Download. Add serde and serde_json to Cargo.toml. For formatting JSON first, use the JSON Formatter.
JSON to Rust Examples
Here is an example of generating Rust structs from a JSON object.
Example: Subscriber record
JSON input:
Generated Rust output:
When JSON to Rust Helps
When building CLI tools, web services (Actix, Axum, Rocket), or async runtimes that consume REST APIs, you need typed structs for the response payload. Pasting a sample response here gives you Serde-compatible structs you can use with reqwest, surf, or any HTTP client. Manually writing structs for complex nested JSON is error-prone; this tool infers the structure from your sample.
For pulling out specific values from large responses first, use the JSON Path tool. For validation, use the JSON Validator. Cargo dependencies: serde = { version = "1.0", features = ["derive"] } and serde_json = "1.0".
Frequently Asked Questions
Optional fields?
Use Option<T> for optional JSON fields. Serde handles null and missing keys automatically. Without Option, missing fields will cause a deserialization error.
How do I rename JSON keys?
Add #[serde(rename = "json_key")] above the field. For snake_case to camelCase, use #[serde(rename_all = "camelCase")] on the struct. See Serde attributes.
Is my data private?
Yes. Generation runs entirely in your browser. No JSON or code is sent to any server.
What about reqwest?
reqwest can deserialize JSON directly: response.json::<YourType>(). Generate the structs here, then use them with reqwest's .json() method.
Serde vs serde_json?
Serde is the serialization framework; serde_json is the JSON implementation. You need both. Add features = ["derive"] to serde for #[derive(Deserialize, Serialize)].
Related Tools
Serde. serde_json. JSON spec. RFC 8259. MDN.