JSON Formatter & Validator
Beautify, minify and validate JSON, see the exact line and column of any error, fix common mistakes in one click, explore it as a tree and convert it to CSV, YAML, TypeScript or XML. Free, and your data never leaves your browser.
How to format and validate JSON
Paste your JSON into the left box, or press Open file, or drop a file onto it. The page checks it as you type. If it is valid you see a green tick and the formatted result on the right; if not, you see the exact line and column, a few characters of context with a caret under the problem, and a Go to error button that puts your cursor there. Choose 2 spaces, 4 spaces, a tab, or Minified from the Indent menu to beautify or compress the output, then use Copy, Download, or Use as input to replace what you pasted.
What each tab does
- Result: the formatted or minified JSON with syntax colours. Options let you sort keys A to Z and escape non-ASCII characters as \uXXXX for systems that need plain ASCII.
- Tree: a collapsible view for exploring large documents. Click any key to copy its path, such as
$.store.books[0].title. Branches draw only when you open them, so big files stay quick. - Convert: turns the JSON into CSV, YAML, TypeScript interfaces or XML, or into an escaped string that you can paste inside code or another JSON value.
- Find: run a JSONPath query or search for any word across keys and values, and copy the matching values as a new JSON list.
The most common JSON errors and how to fix them
| Mistake | Example | Fix |
|---|---|---|
| Trailing comma | {"a": 1,} | Remove the last comma |
| Single quotes | {'a': 'b'} | Use double quotes for keys and strings |
| Unquoted key | {a: 1} | Write "a" |
| Missing comma | {"a":1 "b":2} | Add a comma between items |
| Comment | // note | Delete it; JSON has no comments |
| Python or JavaScript values | True, None, undefined, NaN | Use true, false, null or a number |
| Leading zero or plus | 007, +5 | Write 7 and 5, or quote the value as text |
| Line break inside a string | a real new line in "text" | Write \n instead |
| Text cut off | {"a": [1, 2 | Close the brackets, or copy the full response |
Numbers, key order and duplicate keys
Many online formatters run your text through JavaScript’s JSON.parse, which quietly rounds long numbers (a 19-digit ID changes) and moves numeric-looking keys to the front. This page reads the text with its own parser instead, so numbers are written back exactly as you supplied them and keys keep their order. If the same key appears twice in one object you get a warning with the line number, because most programs keep only the last value without telling you.
Converting JSON to other formats
CSV works best for a list of similar objects: one row each, one column per key, nested objects flattened to names like address.city. YAML keeps the same structure in a more readable form, and quotes text that could be mistaken for a number or true/false. TypeScript creates interfaces from your sample, marking keys that are missing from some items as optional. XML repeats a tag for each list item and replaces characters that are not allowed in tag names. These conversions give you a solid first draft; for a production schema, review the output against the real data.
Using JSONPath in the Find tab
Start with $ for the whole document. Then add .name for a key, [0] for a list position, [-1] for the last item, [0:3] for a range, [*] for every item, ..name to look at any depth, and [?(@.price<10)] to filter. Filters accept ==, !=, <, <=, > and >=, joined with && or ||. Different libraries implement JSONPath slightly differently, so check an unusual expression in the tool you will actually run it in.
Privacy
Everything happens on your device. Your JSON is not uploaded, logged or stored, and the page keeps nothing after you close it. Use the tool freely with internal API responses or configuration, but remember that anything you copy out of it lands on your clipboard like any other text.
Frequently asked questions
Is my JSON uploaded anywhere?
No. Formatting, validation and every conversion run in your browser, and nothing is sent to a server. That makes it safe to paste API responses, config files and test data. The page does not save your input either: close the tab and it is gone.
How do I fix ‘Unexpected token’ or ‘Invalid JSON’ errors?
Look at the line and column shown under the input and press Go to error. The most common causes are a trailing comma after the last item, single quotes instead of double quotes, a key without quotes, a missing comma between two items, or a comment. When the page can repair the text safely, a Try to fix automatically button appears, and an Undo button brings your original back.
What does Try to fix automatically change?
It accepts text that is almost JSON and rewrites it as strict JSON: it removes comments and trailing commas, turns single-quoted strings and unquoted keys into double-quoted ones, adds missing commas between items, changes Python True, False and None to true, false and null, and closes brackets that were left open when the text was cut off. It lists exactly what it changed. It cannot guess missing data, so always read the result.
Does it change my numbers or the order of keys?
No. Numbers are kept exactly as you wrote them, so a 20-digit ID is not rounded the way JavaScript’s JSON.parse would round it, and 1.0 stays 1.0. Keys stay in their original order, including keys that look like numbers. If you tick Sort keys, the output is ordered A to Z instead.
Why does a valid-looking file show an error?
JSON is stricter than JavaScript. Keys and strings need double quotes, there are no comments, no trailing commas, no undefined, NaN or Infinity, and numbers cannot start with a plus sign, a dot or a leading zero. A line break inside a string must be written as \n. The message points at the first place that breaks a rule.
What happens with duplicate keys?
JSON technically allows the same key twice in one object, but most programs silently keep only the last value. The page warns you with the line number so you can decide which one you meant. Nothing is removed for you.
How does JSON to CSV work?
A list of objects becomes a table: each object is a row and each key is a column. Nested objects are flattened into columns such as address.city. A list inside a row is kept as JSON text in one cell, because there is no single right way to spread it across columns. You can pick comma, semicolon or tab as the separator.
Is the TypeScript output exact?
It is a good starting point rather than a guarantee. Types are guessed from the one example you paste, so a key that is missing from some items is marked optional, and a value that is sometimes a string and sometimes null becomes string | null. If your data has rare shapes that are not in the sample, add them to the interface by hand.
What is JSONPath and how do I use the Find tab?
JSONPath is a small query language for picking values out of JSON. Start with $ for the root, then use dots for keys, [0] for a list position, [*] for every item, .. to search at any depth, and filters such as [?(@.price<10)]. In the Find tab you can also just type a word to see every key or value that contains it, with a copyable path for each one.
How large a file can I use?
You can open a file up to 20 MB. A few megabytes work smoothly because the tree only draws the branches you open and long lists are shown 200 items at a time. Very large files depend on your device’s memory, and syntax colouring is switched off for very large results to keep the page responsive.
Can it read JSON Lines (one JSON object per line)?
Yes. If the text is not one JSON value but every non-empty line is valid JSON, the page reads it as JSON Lines and shows it as a list. You can then format it, browse it or convert it to CSV.
Does it support JSON5 or JSONC (JSON with comments)?
Strict validation follows the official JSON rules, so comments and trailing commas are reported as errors. The Try to fix button understands the common JSON5 and JSONC habits (comments, trailing commas, single quotes, unquoted keys) and converts them to standard JSON, but it is not a full JSON5 parser.
Related tools
Base64 Encode & Decode JWT Decoder Markdown Converter Case Converter Word Counter Password Generator All converters