Works on this device
JSON Formatter & Validator
Paste JSON to make it easy to read, to make it small, or to check it for mistakes. The tool shows the line and column of the first mistake. Your text is read in this browser and is not uploaded.
Your JSON
Check these values
Your values are worked out in this browser. They are not sent to a server.
Your result will show here
Type or paste JSON, or choose Try an example.
Result
How it was worked out
How to use this tool
- Type or paste your JSON in the box, or choose Or open a JSON file from your device. The result updates as you type.
- Choose what you want to do: format, minify, check, view as a table, repair, or check against a JSON Schema.
- To format, choose an indent of 2 spaces, 4 spaces or 1 tab. Tick Sort the keys if you want the keys of every object in A to Z order.
- Choose Copy text or Download file to keep the result. Download CSV saves the counts and every row of the table.
What each option does
- Format (beautify) JSON puts each value on its own line with indents. It also counts the objects, arrays, keys, strings and numbers, and shows the size before and after in bytes.
- Minify JSON removes all white space between values.
- Check if JSON is valid says if the text follows the JSON rules. If it does not, you get the line, the column and a short reason, and the line is shown with a mark under the place.
- View JSON as a table lists every value with its path, its type and its value. A path such as
/address/cityis a JSON Pointer. - Repair broken JSON corrects some common mistakes and lists every change it made.
- Check JSON against a JSON Schema tests your data against the rules in a schema and lists every rule that is broken.
The JSON rules that are checked
The tool has its own reader for the JSON standard (RFC 8259). It reads the text one character at a time and stops at the first place that breaks a rule.
- Text and keys must be in double quotes. Single quotes are not JSON.
- Values in a list or object are separated by commas. A comma after the last value is not allowed.
- A number cannot start with a plus sign or with a zero followed by more digits.
NaNandInfinityare not JSON. - Only
true,falseandnullare written without quotes, in small letters. - A string cannot hold a real line break or tab. Write
\nor\t. - Comments are not allowed. The text holds one value only.
Your numbers and strings are not changed
Many formatters read a number into the computer and write it back, so 1.10 becomes 1.1 and 12345678901234567890 becomes 12345678901234567000. This tool keeps every number and every string exactly as you typed it. Formatting and minifying change white space only.
If the same key is used twice in one object, both copies are kept and you get a warning with the line and column of each one.
What the repair option corrects
- A comma after the last value, as in
[1, 2,]. - Strings in single quotes, as in
'text'. - Keys with no quotes, as in
{name: 1}. The key must be made of letters, digits,_or$. - Comments that start with
//or are between/*and*/. True,FalseandNonefrom Python becometrue,falseandnull.undefined,NaN,Infinityand-Infinitybecomenull. This is not the same value, so the list of changes names each one.- Other mistakes, such as a missing comma or a missing bracket, are not repaired. The tool shows where the first one is.
The JSON Schema keywords that are checked
A JSON Schema is a JSON text that says what the data may hold. This tool checks a part of draft 2020-12. Any other keyword in your schema is listed as not checked. It is never left out without a note.
- Any value:
type,enum,const. - Numbers:
minimum,maximum,exclusiveMinimum,exclusiveMaximum,multipleOf. Numbers are compared exactly, with no rounding. - Strings:
minLength,maxLength,pattern. Length is counted in characters. - Lists:
items,prefixItems,minItems,maxItems,uniqueItems,contains. - Objects:
properties,required,additionalProperties,patternProperties,minProperties,maxProperties. - Joining rules:
allOf,anyOf,oneOf,not,ifwiththenandelse. $refto a place inside the same schema, such as#/$defs/addressor#/definitions/address.formatis a note only in this draft. It is listed as not checked, so"format": "email"does not test an email address. Usepatternfor that.
Worked example
The text {"name":"Ada","tags":["a","b",]} is not valid JSON. The check gives Line 1, column 30: this comma has no value after it. Remove the comma. The repair option removes that comma and lists the change as Removed a trailing comma at line 1, column 30.
The valid text {"b":1.10,"a":[true,null]} is 26 bytes. Formatted with 2 spaces it has 7 lines and is 48 bytes. The number is still 1.10. It has 1 object, 1 array, 2 keys, 1 number, 1 true or false value and 1 null value, and the deepest nesting is 2 levels.
With the schema {"type":"object","required":["id"],"properties":{"age":{"type":"integer","minimum":18}}}, the data {"age":15} gives 2 problems: the key id is missing, and at /age the value 15 is less than the minimum 18.
Limits you should know
- Valid JSON has no writing mistakes. It does not mean the data in it is correct or complete.
- The check stops at the first mistake. Correct it and run the check again to find the next one.
- The tool takes up to 5,000,000 characters, files up to 5 MB, and data nested up to 200 levels deep. The table shows up to 200,000 values; the page shows the first 500 rows and the CSV file has them all.
- A repair changes the way the text is written. It cannot know what the author meant, so read the list of changes.
- The schema check covers only the keywords listed above. A
$refto another file or web address is not fetched. Schemas written for older drafts can mean something else. - Schema patterns use the regular expression rules of your browser.
- A JSON file from an address on the web cannot be opened here. Copy the text and paste it, or save the file and open it.
- Formats that are close to JSON, such as JSON Lines, JSON5 or YAML, are not read as such.