JSON to Rust Struct Converter (serde)
Convert JSON to Rust structs with #[derive(Serialize, Deserialize)]. snake_case field names, #[serde(rename)] for mismatched keys, Vec<T> for arrays, and reserved-keyword raw identifiers. 100% local.
Last updated:
Paste JSON to generate Rust structs with #[derive(Debug, Clone, Serialize, Deserialize)]. snake_case fields, #[serde(rename)] for keys that don't match, Vec<T> for arrays, and raw identifiers (r#) for reserved keywords. 100% local.
Tips & Best Practices
- ▸Integer default is i64 — narrow to u32 / i32 / u64 if your domain requires it.
- ▸For fields that may be missing or null, wrap the type in Option<T> and add #[serde(default)].
- ▸The generated structs derive Debug and Clone by default — remove them if you need to keep the struct !Clone (e.g. holding non-Clone resources).
Frequently Asked Questions
Which serialization crate does the output use?
serde with serde_derive — the standard Rust JSON stack. Each struct gets #[derive(Debug, Clone, Serialize, Deserialize)] so it's ready for both serialization and deserialization out of the box.
How are field names converted?
JSON keys are converted to Rust snake_case. When the Rust name differs from the JSON key (or when the key clashes with a Rust keyword), a #[serde(rename = "...")] attribute is added so serde still maps them correctly.
How are numbers typed?
Integers become i64 by default; numbers with a decimal point become f64. Adjust to u32 / f32 / u64 as your domain requires — serde will attempt the conversion at deserialize time.
Is my JSON uploaded anywhere?
No. All conversion happens locally in your browser.
Related Tools
JSON → TypeScript
Convert JSON to TypeScript interfaces instantly. Generate strongly-typed TS types from any JSON sample.
JSON → Go
Convert JSON to Go structs online. Generates idiomatic Go structs with proper json tags and PascalCase field names.
JSON → Python
Convert JSON to Python @dataclass definitions with typed fields. snake_case field names, nested classes, List[T] for arrays, and JSON-key alias comments. 100% local.
JSON → PHP
Convert JSON to PHP 7.4+ classes with typed properties. Generates one class per nested object, phpdoc @var array<T> for typed arrays, and camelCase property names. 100% local.
JSON → Java
Convert JSON to Java POJOs with Jackson @JsonProperty annotations, camelCase field names, List<T> for arrays, and generated getters/setters. Optional package declaration. 100% local.
JSON → C#
Convert JSON to C# classes with System.Text.Json [JsonPropertyName] attributes, PascalCase properties, List<T> for arrays, and optional namespace. Works in .NET 6 / 7 / 8 / 9. 100% local.