JSON to Rust Serde
use serde::{Serialize, Deserialize};
use serde_json;
#[derive(Debug, Serialize, Deserialize)]
pub struct User {
pub id: i64,
pub name: String,
pub email: String,
pub age: i64,
pub active: bool,
pub score: f64,
pub tags: Vec<String>,
pub address: Address,
pub metadata: Option<String>,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct Address {
pub street: String,
pub city: String,
}Last updated:
This tool is provided as-is for convenience. Output should be verified before use in any production or critical context.
Programmatic Access
JSON to Rust Serde is also callable as a free HTTP JSON API at
https://aidevhub.io/api/json-to-rust-serde/ — GET with query
parameters or POST with a JSON body, no authentication, CORS enabled,
50 requests/day per IP. Responses return
{ ok, tool, result, meta }.
curl -s -X POST https://aidevhub.io/api/json-to-rust-serde/ \
-H "Content-Type: application/json" \
-d '{"json":"{\"id\":1,\"name\":\"Alice\"}","root_name":"User"}' Machine-readable contract: /api/tool/json-to-rust-serde.json All API endpoints: /agents/ LLM site index: /llms.txt
Agent Invocation
Best Path For Builders
Dedicated API endpoint
Deterministic outputs, machine-safe contracts, and production-ready examples.
Dedicated API
https://aidevhub.io/api/json-to-rust-serde/ OpenAPI: https://aidevhub.io/api/openapi.yaml
Unified Runtime API
https://aidevhub.io/api/tools/run/?toolId=json-to-rust-serde&a=...
GET and POST are supported at /api/tools/run/ with identical validation and limits.
Limit: 60 req / 60s, input max 128 KB.
How to Use JSON to Rust Serde
- 1
Paste your JSON data
Input a JSON object or array in the left panel. The tool parses the structure and infers Rust types: strings become String, integers become i64, decimals become f64, booleans become bool, and null becomes Option<T>.
- 2
Configure struct options
Set the root struct name (default: Root). Toggle Option<T> wrapping for nullable fields. Enable #[serde(rename_all)] attributes for snake_case or camelCase mapping. Choose between owned String and borrowed &str types.
- 3
Review generated Rust structs
The right panel shows Rust structs with #[derive(Serialize, Deserialize)] and proper serde attributes. Nested objects become separate named structs. Copy the output into your Rust project alongside your serde dependency.