How JSON types map to Rust
| JSON | Rust |
|---|---|
| string | String |
| whole number | i64 |
| decimal | f64 |
| true/false | bool |
| object | struct |
| array | Vec<T> |
| null / optional | Option<T> |
Good to know
- Cargo.toml:
serde = { version = "1", features = ["derive"] }andserde_json = "1".
Related tools
Frequently asked questions
How do I deserialize JSON into a Rust struct?
Add serde (with the derive feature) and serde_json to Cargo.toml, then call serde_json::from_str::<Root>(&text).
Why #[serde(rename)]?
Rust fields use snake_case; rename keeps the exact JSON key, such as fullName.
What are raw identifiers like r#type?
Keys that are Rust keywords (type, match, ref) use the r# prefix so they compile.
Why i64 and f64?
They safely hold typical JSON numbers. Use u32, i32 or f32 where you know the range.
What is serde_json::Value?
A type that can hold any JSON value – used when a field’s type cannot be inferred.
What does skip_serializing_if do?
It omits None fields when you serialise back to JSON.
Do I need #[serde(deny_unknown_fields)]?
Only if you want decoding to fail on unexpected keys; by default extra keys are ignored.
Can I borrow strings instead of String?
Yes – use &str with lifetimes for zero-copy parsing, at the cost of more complex code.
Does it derive Clone and Debug?
Yes – remove them if you do not need them.
How are nested objects named?
From their JSON key in PascalCase – the "address" object becomes Address; array items get a singular name, so "orders" becomes Order.
What happens when array items differ?
All items are merged into one type. Keys missing from some items become optional, and an int that is sometimes a decimal becomes a floating-point number.
How is null handled?
A field that is null in your sample becomes nullable; if it is only ever null, its type cannot be known and a generic type is used – replace it with the real type.
Can I upload a .json file?
Yes – use Open file, or paste the text.
Are dates detected?
No. JSON has no date type, so dates stay strings – convert them after decoding if you need date objects.
Is it free?
Yes – no sign-up, no limits and no watermark.
Is my code uploaded?
No. Everything runs in your browser; nothing you paste is sent to Docelora.
Can I use the output in commercial projects?
Yes. The output is yours to use however you like.
Does it work on a phone or tablet?
Yes – the layout adapts to small screens, though long code is easier to read on a larger display.
How do I copy the result?
Use the Copy button under the result, or Download to save it as a file.
Which browsers are supported?
Current versions of Chrome, Edge, Firefox and Safari.
Last reviewed: 16 November 2026.