Free · No sign-up · Runs in your browser

JSON to Rust Struct Converter

Generate Rust structs with Serde derives, renamed fields, nested models and Option types from JSON sample records.

STEP 1

Start with your input

Edit the example or replace it with your own text.

How to use JSON to Rust Struct Converter

  1. Paste one JSON object or a non-empty array of sample objects.
  2. Generate Serde-ready structs inferred from all records.
  3. Review optional fields and mixed-value fallbacks, then add serde and serde_json to your Rust project.

Model JSON with explicit Rust types

The generator infers String, bool, i64 and f64, creates nested structs, and maps arrays to Vec. Null or missing fields become Option. Heterogeneous values that do not share one Rust representation use serde_json::Value. Serde rename attributes preserve original JSON keys even when field names must be normalized or disambiguated.

Review inference before using generated code

A sample cannot prove that a field is always required or that every future array has the same element shape. Empty arrays and null-only fields use a generic Value fallback. Integers outside JavaScript’s safe range are rejected to avoid silently emitting types from already rounded identifiers. The input array represents multiple examples of Root; deserialize an actual array as Vec<Root>. Missing and explicit null both map to None in this model.

Example input

[{"userId":1,"profile":{"name":"Ada"},"tags":["admin"]},{"userId":2,"profile":null}]

Does this preserve the difference between absent and null fields?

No. Generated Option fields map both cases to None. Use a custom presence model when your API distinguishes them.

Is input uploaded?

Processing takes place in your browser. This tool does not send your input or selected files to a conversion API.

Related tools and guides

Practical guides for this tool

Browse all developer tools