JSON to Rust Struct: quick start guide

Everything you need for a first successful run: what to paste in, which option actually matters, and how to read the result.

Input JSON to Rust Struct Output Runs 100% in your browser — your data never leaves your device.
JSON to Rust Struct — Input → Output. Runs 100% in your browser — your data never leaves your device.

How to use

  1. Open the tool and paste your input into the left pane.
  2. Set only the options your task actually needs — the defaults are correct for most inputs.
  3. Read the result in the right pane; it updates as you type.
  4. Use Copy to take the result, or Download to save it as a file.
How to use · JSON to Rust Struct 1 Paste your data intothe input box (or loadthe example). 2 Configure the optionsto match your targetformat or scenario. 3 Copy, download orinspect the output —it updates live as youtype.
How to use — 3

Examples

Emits serde rename attributes so the Rust field names can stay idiomatic.

Input

{"id":42,"title":"Hello","tags":["a","b"],"active":true}

Output — Results

use serde::{Deserialize, Serialize};

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Root {
    #[serde(rename = "id")]
    pub id: i64,
    #[serde(rename = "title")]
    pub title: String,
    #[serde(rename = "tags")]
    pub tags: Vec<String>,
    #[serde(rename = "active")]
    pub active: bool,
}

Run

Description

Generate a serde-derived Rust struct with rename attributes from a JSON sample.

JSON to Rust Struct → · How to use → · Data Conversion Tools →

Related tools