JSON Deserialize Online
Paste JSON and get the classes it deserializes into, in C#, TypeScript, Java or Python, with the line of code that does it. Escaped JSON strings are unescaped first.
JSON text → objects in your code
Valid JSON · object with 7 keys · 3 levels deep · 248 bytes
using System.Collections.Generic;
using System.Text.Json.Serialization;
// var data = JsonSerializer.Deserialize<Root>(json);
public class Root
{
[JsonPropertyName("bookingId")]
public int BookingId { get; set; }
[JsonPropertyName("hotel")]
public string Hotel { get; set; }
[JsonPropertyName("checkIn")]
public string CheckIn { get; set; }
[JsonPropertyName("nights")]
public int Nights { get; set; }
[JsonPropertyName("total")]
public double Total { get; set; }
[JsonPropertyName("guests")]
public List<Guest> Guests { get; set; }
[JsonPropertyName("paid")]
public bool Paid { get; set; }
}
public class Guest
{
[JsonPropertyName("name")]
public string Name { get; set; }
[JsonPropertyName("email")]
public string? Email { get; set; }
[JsonPropertyName("age")]
public int Age { get; set; }
}2 classes · 10 properties. A key missing from some list items, or null in some, becomes optional or nullable.
Everything runs in your browser; nothing is uploaded.
What does deserialize JSON mean?
Deserializing JSON means turning JSON text into objects in your program. Serializing is the reverse: turning objects into JSON text to save or send. An API sends you a serialized order as text; your code deserializes it into an Order object so you can write order.Total instead of searching through a string.
In typed languages like C# and Java you need a class whose properties match the JSON, which is what this tool writes for you. Every language has a function for each direction:
| Language | Deserialize (JSON → object) | Serialize (object → JSON) |
|---|---|---|
| C# (System.Text.Json) | JsonSerializer.Deserialize<T>(json) | JsonSerializer.Serialize(obj) |
| C# (Newtonsoft) | JsonConvert.DeserializeObject<T>(json) | JsonConvert.SerializeObject(obj) |
| Java (Jackson) | mapper.readValue(json, T.class) | mapper.writeValueAsString(obj) |
| Python | json.loads(text) | json.dumps(obj) |
| JavaScript | JSON.parse(text) | JSON.stringify(obj) |
| PHP | json_decode($json) | json_encode($value) |
How to deserialize JSON online
- Paste a real sample of the JSON, or open a file. If it is full of
\"(JSON stored as text, often copied from a log or database), select Unescape it first. - Pick your language and, for C#, the library your project uses. Set the class name, for example Booking.
- Copy or download the code. The first comment line is the call that deserializes your JSON into those classes.
- Check the types. The tool can only see your sample. Dates arrive as text, and a field that happened to be a whole number may sometimes have decimals, so adjust those by hand.
Use a sample with several list items if you can. Keys that appear in only some items are marked optional, and values that are sometimes null are marked nullable. To just look inside the JSON, use the JSON Parser.
Example: deserialize a booking in C#
A hotel API returns this booking (the example in the tool). The second guest has no email address.
Step 1: Generate the classes (class name Booking)
Email is string? because one guest doesn’t have it. The attributes map the JSON’s camelCase names onto C#’s PascalCase properties.
Step 2: Deserialize and use it
The price per night is 137.5. Without the [JsonPropertyName] attributes, every property would silently stay 0 or null, because System.Text.Json matches names exactly.
Why deserialization fails or gives empty values
| What you see | Cause | Fix |
|---|---|---|
| C# properties are all 0 or null, no error | System.Text.Json is case-sensitive: "qty" doesn’t fill Qty | Add [JsonPropertyName], or set PropertyNameCaseInsensitive = true |
The JSON value could not be converted to System.Int32 | The value is text ("2"), has decimals (2.5) or is too big | Use string, double or long; or allow numbers from strings |
Cannot deserialize the current JSON array … into type 'Root' | The JSON is a list, but you asked for one object | Deserialize into List<Root> |
Error converting value "{"id":7}" to type 'Root' | The JSON was escaped into a string (serialized twice) | Unescape it first, or deserialize to string, then again |
UnrecognizedPropertyException: Unrecognized field | Jackson found a key your Java class doesn’t have | @JsonIgnoreProperties(ignoreUnknown = true) |
| Dates come through as text | JSON has no date type; "2026-11-02" is a string | Change the type to DateOnly (C#), LocalDate (Java, with JavaTimeModule) or date (Python) |
The first row catches people most, because nothing fails: you just get empty objects. Newtonsoft.Json ignores case, so the same classes work there without attributes. It also reads "2" into an int, where System.Text.Json throws.
How to deserialize JSON in code
// C# (System.Text.Json, built into .NET)
var booking = JsonSerializer.Deserialize<Booking>(json);
var list = JsonSerializer.Deserialize<List<Booking>>(json); // JSON array
// C# (Newtonsoft.Json)
var booking = JsonConvert.DeserializeObject<Booking>(json);
// Java (Jackson)
Booking booking = new ObjectMapper().readValue(json, Booking.class);
# Python: a plain dict, or a checked model with Pydantic
data = json.loads(text)
booking = Booking.model_validate_json(text)
// TypeScript: the type is a promise, not a check
const booking = JSON.parse(json) as Booking;In TypeScript, as Booking only tells the compiler what to expect. Nothing checks the data at run time, so a missing field shows up later as undefined. Pydantic in Python and the C# and Java libraries do check, and fail with a message instead.
Frequently asked questions
What is the difference between serialize and deserialize?
Serializing turns objects in memory into JSON text, for example to send in an API response or save to a file. Deserializing reads that JSON text back into objects. JSON.stringify and JSON.parse are the JavaScript versions.
What does deserializing an escaped JSON string mean?
Text like "{\"id\":7}" is JSON that was serialized twice, so the outer layer is just a string. Deserialize it to a string first, then deserialize that string into your class. Here, select Unescape it and the tool does the first step for you.
Can I deserialize JSON without writing classes?
Yes. Read it into a general structure instead: JsonDocument or JsonNode in C#, JsonNode from readTree in Java, a dict in Python or a plain object in JavaScript. Classes are worth it when you use the data in many places, because the compiler then checks every property name.
Is it safe to deserialize JSON from users?
Reading JSON into your own classes is safe. The risk comes from settings that let the JSON choose which class to create, such as Newtonsoft TypeNameHandling or Jackson default typing. Leave those off for data you don’t trust, and validate values such as lengths and ranges.
Sources
- Microsoft Learn: How to read JSON as .NET objects: System.Text.Json deserialization
- Microsoft Learn: Case-insensitive property matching: why properties stay empty
- Newtonsoft.Json: Deserialize an object: JsonConvert.DeserializeObject
- Jackson databind: ObjectMapper.readValue and unknown properties
- Pydantic: JSON: model_validate_json
- OWASP: Deserialization cheat sheet: type-name handling risks
Related Tools
Build and preview Valorant crosshair settings.
Search common Vim commands.
Turn JSON rows into bar, line, or pie charts.
Convert WebP files and Base64 data in both directions.
Convert GIF files and Base64 data in both directions.
Save any GIF frame, or all frames, as JPG.