JSON Formatter
Pretty-print, validate and minify JSON with friendly error messages.
Turn any JSON into ready-to-compile Rust struct definitions with serde derives.
Your result is ready — download it below:
Re-encoded without size gain Download links expire within 30 minutes.
No result to display for the current input.
Turn any JSON into ready-to-compile Rust struct definitions with serde derives.
Paste any JSON document and get idiomatic Rust struct definitions in seconds. The generator infers field types, wraps nulls in Option, turns arrays into Vecs, and emits nested structs for objects — with serde derives and the exact Cargo dependencies you need. Everything runs in your browser or on a server endpoint and is never stored.
Paste a JSON document, choose a root struct name and whether to include Serialize/Deserialize derives, then press Run. The generator walks the document and creates one struct per object, named from the JSON path — address becomes Address, company.address becomes CompanyAddress. Arrays produce Vec<T>; when an array holds objects, their fields are merged across every sample so a key missing from some entries automatically becomes Option<T>.
Booleans map to bool, integers to i64, floats to f64 and strings to String. A null value becomes Option<T> (or Option<serde_json::Value> when the type cannot be determined). Mixed integer/float values are unified to f64; anything genuinely ambiguous falls back to serde_json::Value, which always compiles.
JSON keys become snake_case Rust field names automatically, so firstName becomes first_name and first-name becomes first_name. Rust keywords such as type or match are emitted as raw identifiers (r#type). When a field name differs from the original key, a #[serde(rename = "...")] attribute is added so deserialisation still matches the original JSON exactly.
If your JSON is an array or a scalar rather than an object, the generator wraps it in a newtype struct — for example pub struct Root(pub Vec<Item>); or pub struct Root(pub String); — with the inner type defined alongside it.
Your JSON is processed only to produce the Rust code and is never stored, logged or shared. There is no upload, no account and no watermark.
Yes. The snippet includes the use statement and the Cargo dependencies require comment. Add serde (with the derive feature) and, when noted, serde_json to your Cargo.toml and it compiles as-is. Choose the "Debug, Clone only" option to skip serde entirely.
Fields whose value is null become Option<T>. If the type cannot be inferred from other samples, they become Option<serde_json::Value>, which always compiles.
Generated struct names are kept unique: when a path has already been used, a numeric suffix (Address2) is added so the output is always valid Rust.
JSON to Rust Struct Generator converts a JSON document into idiomatic Rust struct definitions. Objects become their own structs, arrays become Vecs, null becomes Option, and nested objects are generated as separate types with path-based names (e.g. address becomes Address, company.address becomes CompanyAddress).
How to use: paste some JSON, optionally pick a root struct name and whether to emit Serialize/Deserialize derives, then press Run. A copy-ready Rust snippet is returned, including the Cargo dependencies you need.
Optionr#type) and serde rename keeps the original JSON keysPretty-print, validate and minify JSON with friendly error messages.
Turn any JSON into a TypeScript Zod schema with nullable and optional handling.
Convert any JSON into Go struct definitions with json tags and pointers for optionals.
Decode JWT header and payload instantly, 100% in your browser — the token never leaves your device.