Code tool

JSON to Rust Struct Generator

Sample inference only. Missing keys across object-array samples become optional; null stays nullable, mixed arrays use a union or a general JSON value, and empty arrays carry no element-type evidence. A single sample cannot establish required fields. Output is text only; data stays in this page.

In-browser processingNo account requiredPrivacy details ↗

Sample inference only. Missing keys across object-array samples become optional; null stays nullable, mixed arrays use a union or a general JSON value, and empty arrays carry no element-type evidence. A single sample cannot establish required fields. Output is text only; data stays in this page.

Paste JSON, then generate.

Serde draft uses f64 for observed numbers; heterogeneous arrays use serde_json::Value. Empty arrays use Vec<Value>; null uses Option<Value>. Keys are snake_case ASCII, with deterministic suffixes for collisions and Serde rename to retain original JSON keys. Review number precision and Option missing/null semantics. Requires serde derive and serde_json in your project. JSON keys containing unpaired UTF-16 surrogates are rejected.

Invalid JSON or limit exceeded: 100,000 input characters, depth 30, 10,000 nodes, 200,000 output characters. Nonfinite or unsafe integer numbers are rejected.

A QUICK WALKTHROUGH

How to use this tool

  1. Paste a bounded JSON sample.
  2. Choose optional fields, then generate.
  3. Review the draft and copy it.

Draft output

Serde draft uses f64 for observed numbers; heterogeneous arrays use serde_json::Value. Empty arrays use Vec<Value>; null uses Option<Value>. Keys are snake_case ASCII, with deterministic suffixes for collisions and Serde rename to retain original JSON keys. Review number precision and Option missing/null semantics. Requires serde derive and serde_json in your project. JSON keys containing unpaired UTF-16 surrogates are rejected.

JSON sample

Invalid JSON or limit exceeded: 100,000 input characters, depth 30, 10,000 nodes, 200,000 output characters. Nonfinite or unsafe integer numbers are rejected.

GOOD TO KNOW

Common questions

Does one sample identify every required field?

No. Inference describes the supplied sample only. Use multiple representative objects and review optional and nullable fields before relying on the draft.

Can I use the generated code without changes?

Review it first. Numbers use f64, empty or heterogeneous arrays may use serde_json::Value, and Option does not by itself distinguish a missing key from null.