What the Page Covers
The page is one workspace with two modes. Parser mode pairs an editor with a collapsible tree, so you can see how the document nests. Validator mode checks the same text against a stricter grammar and reports the first problem it meets. A toolbar above both modes handles rewriting, copying, sample loading and class generation. Every step runs inside your browser tab.
Parser Mode and the Tree View
Type or paste into the left editor and the right-hand Tree View rebuilds itself. The view listens for change, keyup and paste events, so it follows each edit without a button press. Objects and arrays open and close individually, which keeps large documents manageable. Every value carries a class for its type, and the filter menu depends on those classes.
The Copy button in the Tree View header writes the document back out with two-space indentation. It is handy when the text arrived minified and you want to read it.
Validator Mode and Its Messages
Validator mode runs the text through a grammar parser bundled in the site's assets rather than the browser's own JSON reader. Press Validate JSON and the result panel either confirms the text or shows a failure report. That report names the line where parsing stopped, shows the text around that spot, and compares the token the grammar expected with the token it actually met. The Format JSON button in this mode always indents with two spaces and writes the result back into the validator editor.
Some input patterns look harmless but fail under this grammar:
| Input pattern | Why it is rejected | What to change |
|---|---|---|
| Comments with // or /* */ | The grammar has no comment syntax | Delete the comments, or keep them in a separate notes file |
| NaN or Infinity as a number | Neither word is a number literal in the format | Use null, or store the value as a quoted string |
| Leading zeros such as 007 | A number cannot begin with an extra zero | Write 7, or keep the code as a string such as "007" |
| A line break inside a string | Strings must stay on one line | Replace the break with a backslash followed by n |
Toolbar Actions
The toolbar acts on whichever editor is visible, so the same buttons serve both modes.
- Format parses the text and rewrites it using the indent you pick: two spaces, four spaces or a tab. If the text does not parse, the editor is left alone and a notice shows the parser message.
- Minify parses the text and writes the value back with no spaces or line breaks.
- Copy and Download use the editor text as it stands. Download saves a file named data.json.
- Sample fills the editor with a small customer record that has a nested address, a list of roles and a null field.
- Clear empties the editor and the validator result panel.
Format and Minify use the browser's built-in JSON reader, so the wording of their error notices follows the browser.
Stats, Search and Filters
The bar above the editors reports characters, lines and bytes, and it updates as you type. Bytes are counted as UTF-8, so an accented letter or a symbol takes more than one byte. When the text parses, a second readout lists the total number of keys, the deepest nesting level, and how many objects and arrays the document holds. Keys are counted at every depth, while array items are not counted as keys. If the text does not parse, that readout says invalid JSON.
The search box looks through the rendered tree for matching keys and values, highlights the first hit and scrolls it into view. The filter menu narrows the highlighting to objects, arrays, or one value type, and it works together with a search term.
Worked Example
The steps below follow one small input through the toolbar. Each output comes from the rules described above, so you can repeat them in the page and compare.
- Paste the input into the Parser editor:
{ "name": "Ada", "score": 9.50, "tags": ["x", "y"] }. The stats bar reads 52 chars, 1 lines and 52 bytes. - Press Minify. The editor now holds
{"name":"Ada","score":9.5,"tags":["x","y"]}, and the bar reads 43 chars, 1 lines and 43 bytes. The score changed from 9.50 to 9.5 because the number was rebuilt from its parsed value. - Press Format with the indent set to 2 spaces. The editor now holds the text below, and the bar reads 69 chars, 8 lines and 69 bytes.
{
"name": "Ada",
"score": 9.5,
"tags": [
"x",
"y"
]
}
- Read the structure readout. It shows
3 keys · depth 2 · 1 objects · 1 arrays. The keys are name, score and tags. The depth is 2 because the strings inside tags sit two levels below the root object. - Choose C# in the Generate Class dialog and keep the root name as Root. The dialog produces this file:
using System;
using System.Collections.Generic;
using System.Text.Json.Serialization;
public class Root
{
[JsonPropertyName("name")]
public string Name { get; set; }
[JsonPropertyName("score")]
public double Score { get; set; }
[JsonPropertyName("tags")]
public List<string> Tags { get; set; }
}
Each key became a property with a PascalCase name. The original key sits in a JsonPropertyName attribute because the property name differs from it. The score is a double since 9.5 has a fraction, and tags is a list of strings because its first item is a string.
Generating Model Classes
Generate Class opens a dialog that turns the Parser editor into a starter model. Eleven targets are available: C#, Java, Kotlin, Swift, TypeScript, Go, Rust, Python, Ruby, PHP and Dart. The root name is converted to PascalCase, so typing user_profile produces UserProfile. The dialog reads only the Parser editor, never the validator.
- One class per object. A class is named from its key in PascalCase, and array items take the singular form of the key, so an array of objects under tags yields a Tag class. When a name repeats, a number is appended, giving names such as Address and Address2.
- Scalar types. Whole numbers map to integer types and numbers with a fraction map to floating-point types. Strings and booleans map to their native equivalents. A null becomes a loose type that accepts anything, and an empty array becomes a list of a loose type.
- Element types. The first non-null item of an array decides the element type, so a mixed array is described by that first item alone.
- Field names. Names follow each language's convention. C#, Kotlin, Swift, Go and Rust add an attribute or annotation that keeps the original key when the converted name differs. TypeScript keeps the original keys unchanged. Java, Python, PHP, Ruby and Dart add no mapping, so renamed fields need manual work there.
- Bare values. If the root is a single number, string, or boolean rather than an object or array, no class is produced. The output names the plain type instead.
Copy places the generated text on the clipboard. Download saves it under a name built from the root, such as Root.cs for C#.
Frequently Asked Questions
Nothing in the editor changes. Format and Minify parse the text before they rewrite it, and when that parse fails the page shows a short notice containing the parser message while your input stays exactly as it was.
Format and Minify rebuild the output from the parsed value, so every number is written in the standard JavaScript form. A value such as 9.50 becomes 9.5 and 1e3 becomes 1000. Integers larger than the safe range can also lose digits, and a key that appears twice keeps only its last value.
C#, Java, Kotlin, Swift, TypeScript, Go, Rust, Python, Ruby, PHP and Dart. The generator reads the text in the Parser editor and writes one class for every object it finds, so nested objects become separate types.
Treat it as a starting point. Types come from the sample you pasted, so a field missing from that sample will not appear, an array's element type comes from its first non-null item, and null values become loose types. Check the output against your real data before relying on it.
No. Parsing, validating, formatting, searching and class generation all run in your browser, and the tool's own code makes no network request that carries your text.
The Validator uses a strict grammar parser bundled with the site, which reports the line number and the token it expected. The toolbar Format, Minify and Generate Class actions use the browser's built-in JSON reader, so their wording depends on which browser you use.