JSON Formatter & Validator
Format, validate, and beautify JSON instantly. Syntax highlighting, tree view, and error detection.
Formatted JSON will appear here...
Invalid JSON
Valid JSON
Your JSON is properly formatted and valid.
Try Examples
Convert To
Features
Beautify JSON
Format minified JSON into readable, indented structure
Minify JSON
Compress JSON by removing whitespace for smaller file size
Validate JSON
Check if JSON is valid with detailed error messages
Syntax Highlighting
Color-coded syntax for keys, values, strings, and numbers
Tree View
Collapsible tree visualization of JSON structure
Convert Formats
Convert JSON to YAML, XML, CSV, or query string
How to Use the JSON Formatter
- Paste your data into Input JSON, click Upload to open a .json or .txt file, or press one of the Try Examples buttons. The badge beside the box switches between Valid JSON and Invalid JSON as you type, and valid pasted text is beautified automatically.
- Pick an Indent of 2 spaces, 4 spaces (the default) or Tab, then click Beautify. The Output panel shows colour-highlighted JSON with its size in bytes; switch to Tree to fold and unfold objects and arrays, each labelled with its item count, such as Object{3} or Array[5].
- Click Minify to remove every optional space and line break. Minify also replaces the text in the Input JSON box, while Beautify leaves your input as it was.
- Click Validate for a quick yes or no. Invalid input shows a red Invalid JSON box with your browser's error message; in Chrome and Edge the tool also turns the position into a line and column.
- Copy and Download (saved as data.json) use the text in the Input JSON box. To keep a beautified copy, select it in the Output panel; to keep a minified copy, Minify first and then Copy or Download.
- Under Convert To, turn valid JSON into YAML, XML, CSV (arrays only) or a URL query string.
Common JSON Errors and How to Fix Them
Each broken example below was run through this tool in Chrome, and the message shown is exactly what appeared in the error box. Firefox and Safari word their messages differently, but the fixes are the same.
1. Trailing comma
{"name": "Ali", "city": "Lahore",}
Expected double-quoted property name in JSON at position 33 (line 1 column 34)
{"name": "Ali", "city": "Lahore"}
JavaScript accepts a comma after the last item; JSON does not. In an array such as [1, 2, 3,] the message changes to Unexpected token ']', but the fix is the same: delete the last comma.
2. Single quotes, unquoted keys or curly quotes
{'name': 'Ali'}
{name: "Ali"}
{“name”: “Ali”}
Expected property name or '}' in JSON at position 1 (line 1 column 2)
{"name": "Ali"}
All three lines fail at the first key. The third is the sneaky one: text copied from Word, Google Docs or a chat app often carries curly quotes that look almost identical to straight ones.
3. Comments or a missing comma
{
"debug": true // local only
}
Expected ',' or '}' after property value in JSON at position 18 (line 2 column 17)
{
"debug": true
}
The message never mentions comments; it simply points at the character after the value. {"a": 1 "b": 2} gives the same message (at column 9) because a comma is missing, so look at the exact line and column shown.
4. Numbers with a leading zero
{"phone": 03001234567}
Unexpected number in JSON at position 11 (line 1 column 12)
{"phone": "03001234567"}
JSON numbers cannot start with 0. Mobile numbers, CNIC numbers, PIN codes and account numbers are identifiers rather than quantities, so store them as strings; that also keeps the leading zero.
5. Backslashes in Windows paths
{"path": "C:\new\data"}
Bad escaped character in JSON at position 17 (line 1 column 18)
{"path": "C:\\new\\data"}
A backslash starts an escape sequence, so every literal backslash must be doubled. Be careful: "C:\new\temp" is valid, because \n and \t are real escapes, and it quietly turns into C:, a line break, "ew", a tab and "emp".
6. NaN, undefined or Python values
{"total": NaN}
{"on": True}
Unexpected token 'N', "{"total": NaN}" is not valid JSON (first line pasted on its own)
{"total": null}
{"on": true}
JSON only knows true, false and null in lower case, and has no NaN, Infinity or undefined. These errors often come from pasting a Python print() of a dict (True, None, single quotes), or from Python's json.dumps, which writes NaN unless you pass allow_nan=False. For this type of message the tool cannot show a line and column.
JSON vs a JavaScript Object Literal
JSON borrowed its look from JavaScript, but it is a stricter text format meant to be read by any language. Code that works as a JavaScript object will often fail as JSON:
| Feature | JS object | JSON |
|---|---|---|
| Unquoted keys | Allowed | Not allowed |
| Single-quoted strings | Allowed | Double quotes only |
| Trailing commas | Allowed | Not allowed |
| Comments | Allowed | Not allowed |
| undefined, NaN, functions | Allowed | Not allowed |
| Dates | Date objects | Strings, e.g. "2024-01-15T10:30:00Z" |
Big numbers and number formatting
Because the tool parses with JavaScript, integers above 9,007,199,254,740,991 lose precision: {"id": 12345678901234567890} is shown after Beautify as 12345678901234567000. Python's json module keeps that integer exact, so the change comes from JavaScript, and any JavaScript code that reads your API with JSON.parse will hit it too. Beautify and Minify also rewrite numbers in their shortest form, so 1.10 becomes 1.1 and 1e3 becomes 1000. Text in Urdu, Hindi or any other script is kept as-is rather than turned into \u escapes.
Minify vs Beautify, and Checking API Responses
Real sizes for the API Response example
| As loaded into the input | 237 bytes |
| Minify | 215 bytes, 1 line |
| Beautify, Tab | 295 bytes, 22 lines |
| Beautify, 2 spaces | 341 bytes, 22 lines |
| Beautify, 4 spaces | 433 bytes, 22 lines |
Beautify for reading, reviewing and debugging. Minify when the JSON is going into a request body, a database field or a single-line setting, where extra whitespace only adds bytes.
Debugging an API response
- Copy the body from your browser's developer tools (Network tab, Response) or from curl and paste it here.
- Unexpected token '<', "<!DOCTYPE "... is not valid JSON means the server sent an HTML page, usually a login screen or an error page, instead of JSON.
- Unexpected non-whitespace character after JSON usually means several JSON documents on separate lines, as in log files. Validate one line at a time.
- Use the Tree view to find a nested field, and CSV to open an array of records in a spreadsheet. CSV takes its columns from the first object only, so a key that appears only in later objects is left out.
- To spot what changed between two responses, beautify both with the same indent and compare them in the Text Diff tool.
All JSON processing on this page runs in your browser: the tool uses the browser's built-in JSON parser, the Upload button reads the file on your device, and Download builds the file locally; the page's code does not send the API keys or customer records in your JSON to any server. If you are designing the API yourself, our guide to REST vs GraphQL covers how JSON responses are shaped in each, and the Base64 encoder helps when a JSON field carries encoded data.
Frequently Asked Questions
How do I fix "Expected double-quoted property name in JSON"?
In Chrome and Edge this message means the parser reached a spot where a key in double quotes should start. The usual causes are a trailing comma before the closing brace, as in {"city": "Lahore",}, or a key written in single quotes after a comma. Remove the last comma or change the quotes to straight double quotes.
Are comments allowed in JSON?
No. Standard JSON has no comment syntax, so // and /* */ both make the whole document invalid. Some config files, such as VS Code settings, use a relaxed variant that allows comments, but APIs and JSON.parse expect strict JSON, so delete the comments or move the note into a normal key such as "_note".
Can JSON use single quotes?
No. Keys and string values must be wrapped in straight double quotes. Single quotes, and the curly quotes that Word and many phone keyboards insert automatically, make the JSON invalid, so replace them with straight " characters.
Why did my long ID number change after formatting?
The tool uses the browser's JavaScript number type, which stores integers exactly only up to 9007199254740991. A value such as 12345678901234567890 comes out as 12345678901234567000 after Beautify or Minify. Send large IDs as strings, for example "12345678901234567890", to keep every digit.
What is the difference between Beautify and Minify?
Beautify adds line breaks and indentation (2 spaces, 4 spaces or a tab) and shows the result in the Output panel. Minify removes all optional whitespace and also replaces the text in the Input JSON box. For the built-in API Response example, the minified version is 215 bytes and the 4-space version is 433 bytes.
Is my JSON sent to a server?
No. Parsing, formatting, the tree view and the conversions all run in JavaScript in your browser, and the Upload button reads your file locally. The page's script contains no code that sends your JSON anywhere.
Is there a size limit?
The tool sets no size limit of its own. Everything is held in your browser's memory, so how large a file works well depends on your device and browser.
Does valid JSON mean my data is correct?
No. Validation only checks the syntax. Duplicate keys such as {"a": 1, "a": 2} pass and silently keep the last value, and a wrong field name or data type will not be flagged, so compare the output against what your API or app expects.